Flex, Row, Column and Card take the same breakpoint props as on the web: xl, l, m, s and xs. Each one is an object of props that applies on screens up to its width. For the web version, see Breakpoints.
The width is the window's, in points, read by ThemeProvider with useWindowDimensions. It updates when the device rotates, and when an iPad app runs in Split View or Slide Over. useTheme().width and useTheme().breakpoints give the same values to your own components.
The objects apply from the largest to the smallest: the base props, then xl, l, m, s and xs. Each one the width falls within is merged over the ones before it, so a smaller breakpoint wins. This is the order the media queries apply in the browser.
On a 390 point wide phone, m and s both apply, and s is merged last, so the padding is 16. A style set in a breakpoint goes after the base style instead of replacing it.
A common use is laying items out in a row on tablets and stacking them on phones:
hide renders nothing, as display: none does on the web. Combine it with a breakpoint to show a view only on some screens:
A hidden view is not mounted at all, so its state resets when it shows again.
dark renders a view only while the theme is dark, and light only while it is light. They do not change any colours: use them to swap content, such as a logo drawn for each theme. They also work inside a breakpoint object.
The type is exported as FlexBreakpointProps. Card extends Flex, so it takes the same objects.
Phones keep parts of the screen for the notch, the status bar and the home indicator. Pass the insets to ThemeProvider (see Quick start), then add safeArea to a Flex, Row or Column to pad it by them:
- safeArea pads every edge.
- safeArea={["top", "bottom"]} pads only the edges you list.
The insets are added on top of the padding the edge already has, like calc(space + safe-area) on the web, so padding="20" with safeArea stays 20 points clear of the notch. Without insets on ThemeProvider they are all 0 and safeArea adds nothing. safeArea is not a breakpoint prop.
- Points, not pixels. Breakpoints compare the window width in points, which is what useWindowDimensions reports.
- Computed at render. The web renders breakpoint values as classes inside media queries. Native merges the objects in JavaScript for the current width, so every prop works in a breakpoint, including sizes, aspectRatio and style, and nothing waits for hydration.
- Fewer props. solid, borderTop to borderY, onBackground, onSolid, align, textVariant, textSize, textWeight, textType, transition, scrollbar, overflowX and overflowY have no native equivalent and are not supported, in breakpoints or on the base props.
- No fixed or sticky. position takes relative, absolute or static.
- Only layout components. The breakpoint props are on Flex, Row, Column and Card. There is no Grid yet: use a Row with wrap, or change direction at a breakpoint.