React Native · APIs and utilities
Responsive layout
Layout info based on the window: breakpoint, orientation, whether it is a tablet.
Import
useResponsive
functionLayout info based on the window: breakpoint, orientation, whether it is a tablet. If the window changes while the app is open (a foldable opening, split screen, rotation) the component re-renders.
Examples
BREAKPOINTS
constantBreakpoints: the same as the Tailwind scale on web (window width, dp/pt). base covers every width.
breakpointOf
functionThe largest breakpoint the width falls into.
pickResponsive
functionPicks the value from a BreakpointValue based on the width.
useScale
functionThe active scaler: s(20) for sizes, fs(16) for font sizes. When the window changes (foldable, split screen, rotation) the component re-renders with new values. The setting comes from the UIProvider scaling prop.
Examples
createStyles
functionDevice-scaled, theme-bound styles: the counterpart of StyleSheet.create. The pixel values you give (padding: 20, fontSize: 16) are scaled to the window (scaleStyle rules); for colors the function form receives the theme. The returned hook gives new styles when the window or theme changes; for the same scale and theme the result comes from a cache (each component instance does not recompute).
Examples
scaleStyle
functionScales the pixel values in a style object. Only numbers change: percentages ("50%"), "auto", colors, flex, opacity, zIndex, aspectRatio, border widths (borderWidth, so thin lines stay sharp) and values of ±1 or less stay as they are. shadowOffset and translateX/Y inside transform are scaled too.
Examples
DEFAULT_SCALING
constantThe default settings.
createScaler
functionCreates a scaler from a window size. If options is false the factor is 1 (scaling off). If the window size is unknown (0) the factor is 1.
Examples
getScaler
functionThe active scaler (the one of the most recently rendered UIProvider). For code outside components (navigation header settings, animation calculations). Inside components use useScale: it re-renders when the window changes.
scaleSize
functionScales a size with the active scaler (Scaler.s). For use outside components; the value does not refresh by itself when the window changes.
Examples
scaleFont
functionScales a font size with the active scaler (Scaler.fs). See scaleSize.
Breakpoint
typeBreakpoint name. See BREAKPOINTS.
BreakpointValue
typeA value per breakpoint: breakpoints not given inherit from the previous one (the md:grid-cols-2 logic on web).
Extends: Partial<Record<Exclude<Breakpoint, "base">, T>>
| Name | Type | Description |
|---|---|---|
base | T | Value for the smallest widths (and the fallback). |
Examples
ResponsiveInfo
interfaceValue of useResponsive.
| Name | Type | Description |
|---|---|---|
width | number | Window width (dp/pt). |
height | number | Window height. |
orientation | "portrait" | "landscape" | Landscape or portrait. |
breakpoint | Breakpoint | The active breakpoint (by width). See BREAKPOINTS. |
isTablet | boolean | A tablet or an open foldable: the window's short side is 600 or more (Android's sw600dp rule). |
up | (breakpoint: Breakpoint) => boolean | Whether the width is at or above this breakpoint. @example up("md") |
down | (breakpoint: Breakpoint) => boolean | Whether the width is below this breakpoint. @example down("md") → phone |
select | <T>(value: BreakpointValue<T>) => T | Picks a value by width; breakpoints not given inherit from the previous one. |
NamedStyles
typeNamed styles (the same shape as StyleSheet.create).
StyleContext
typeValues received by the function form of createStyles: the theme and the scaler.
CreateStylesOptions
interfaceOptions of createStyles.
| Name | Type | Default | Description |
|---|---|---|---|
scale? | boolean | true | Whether numbers are scaled automatically. When off, only values you give with scale.s() in the function form are scaled. |
ScalingOptions
interfaceScaling settings (the UIProvider scaling prop). Pixel values you give in the design (padding: 20, fontSize: 16) are scaled up or down to the device's window size; so text and spacing do not overflow on small screens or look scrawny on large ones.
The factor is computed from the window's short side (sizes do not jump on rotation) and updates live as the window changes (a foldable opening, split screen, Stage Manager on iPad, the "Display size" setting on Android):
strength 1 means fully linear scaling, 0 no scaling at all; the default 0.5 applies half the difference (text grows proportionally across phones, without becoming huge on tablets).
| Name | Type | Default | Description |
|---|---|---|---|
baseWidth? | number | 390` (iPhone 12–16) | Short side of the screen the design was made for (dp/pt). |
strength? | number | 0.5 | Scaling strength of sizes (0–1). |
fontStrength? | number | 0.4 | Scaling strength of font sizes (fontSize, lineHeight, letterSpacing) (0–1). Text grows a little less than spacing; readability is kept and nothing overflows. |
min? | number | 0.85 | Minimum factor. |
max? | number | 1.2 | Maximum factor (tablets and open foldables). |
maxFontScale? | number | Upper bound of the system font size (accessibility) multiplier; the library's Text component applies it as maxFontSizeMultiplier. If omitted it is unlimited (recommended; respects the accessibility setting). |
Examples
Scaler
interfaceScaler: factors computed for the current window and conversion functions. Obtained with useScale; a new one arrives when the window changes.
| Name | Type | Description |
|---|---|---|
factor | number | Size factor (1 means no scaling). |
fontFactor | number | Font factor. |
width | number | Window width used in the computation. |
height | number | Window height used in the computation. |
maxFontScale | number | undefined | Limit of the system font size multiplier (ScalingOptions.maxFontScale). |
s | (size: number) => number | Scales a size and rounds it to the nearest physical pixel: spacing, width, height, corner radius, icon size. |
fs | (size: number) => number | Scales a font size (fontSize, lineHeight, letterSpacing). |
ms | (size: number, strength: number) => number | Scales with your own strength: strength 0 none, 1 fully linear. |