Layout
Layout is a safe-area wrapper that applies the theme background color for you.
Usage
import { Layout, Typography } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<Layout>
<Typography variant="headlineSmall">Inside safe area</Typography>
<Typography variant="bodyMedium">Theme background applied automatically.</Typography>
</Layout>
</ThemeProvider>
</SafeAreaProvider>
)
}
Immersive Mode
For a full-screen layout that extends behind the status bar:
import { Layout, Typography } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<Layout immersive>
<Typography variant="headlineSmall">Immersive content</Typography>
<Typography variant="bodyMedium">No safe area insets applied.</Typography>
</Layout>
</ThemeProvider>
</SafeAreaProvider>
)
}
Custom Edges
Choose which safe-area edges apply:
import { Layout, Typography } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<Layout edges={['top', 'bottom']}>
<Typography variant="headlineSmall">Top + Bottom insets</Typography>
</Layout>
</ThemeProvider>
</SafeAreaProvider>
)
}
By default, the left, right and bottom edges apply, and top does not, because an AppBar usually owns the top inset. The side insets are 0 in portrait; in landscape they keep the content clear of the notch or the Dynamic Island. In immersive mode, no edge applies. Layout reads edges first, and it overrides immersive: <Layout immersive edges={['top']} /> applies the top inset and ignores immersive.
Layout always paints theme.colors.background and strips backgroundColor
from the style you pass, so the app background stays a single themed surface.
To draw a different background, nest a Box (or any View) inside it.
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
immersive | boolean | false | No | When `true`, removes all safe area insets for full-screen layout. |
edges | Edge[] | ['left', 'right', 'bottom'] | No | Explicit set of safe-area edges to apply. Overrides `immersive` when provided. The top edge is left out by default, because `AppBar` usually owns the top inset — pass `['top', 'left', 'right', 'bottom']` on a screen with no AppBar, or a title placed under the status bar will be clipped. The side edges are in the default: they are 0 in portrait, and in landscape they keep the content clear of the notch or the Dynamic Island. |
style | StyleProp<ViewStyle> | - | No | Additional styles applied to the SafeAreaView container. `Layout` always paints `theme.colors.background` and drops `backgroundColor` from this style. To draw a different background, nest a `Box` or a `View` inside it. |