Skip to main content

Row

Lays children out horizontally. Extends Box with all spacing, alignment, and gap props.

Usage

import { Button, Row } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<View style={{ flex: 1, justifyContent: 'center', padding: 16 }}>
<Row gap="sm" align="center">
<Button variant="filled" onPress={() => {}}>Save</Button>
<Button variant="outlined" onPress={() => {}}>Cancel</Button>
</Row>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}

Wrapping

Enable wrap to let children flow onto the next line when they overflow:

import { Chip, Row } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'

const tags = ['React', 'TypeScript', 'Expo', 'Material', 'Native', 'Components', 'Design']

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<View style={{ flex: 1, justifyContent: 'center', padding: 16 }}>
<Row wrap gap="sm">
{tags.map((tag) => (
<Chip key={tag} onPress={() => {}}>{tag}</Chip>
))}
</Row>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}

Inverted

Reverse the layout direction with inverted:

import { Row, Typography } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<View style={{ flex: 1, justifyContent: 'center', padding: 16 }}>
<Row inverted gap="sm">
<Typography>First</Typography>
<Typography>Second</Typography>
</Row>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}

Props

PropTypeDefaultRequiredDescription
wrapbooleanNoWhether children should wrap to the next line when they overflow.
invertedbooleanNoReverses the layout direction (`row-reverse`).
pSpacingValue-NoPadding on all sides
pxSpacingValue-NoHorizontal padding (paddingStart + paddingEnd)
pySpacingValue-NoVertical padding (paddingTop + paddingBottom)
ptSpacingValue-NoPadding top
pbSpacingValue-NoPadding bottom
psSpacingValue-NoPadding start (left in LTR, right in RTL)
peSpacingValue-NoPadding end (right in LTR, left in RTL)
mSpacingValue-NoMargin on all sides
mxSpacingValue-NoHorizontal margin (marginStart + marginEnd)
mySpacingValue-NoVertical margin (marginTop + marginBottom)
mtSpacingValue-NoMargin top
mbSpacingValue-NoMargin bottom
msSpacingValue-NoMargin start
meSpacingValue-NoMargin end
gapSpacingValue-NoGap between children
rowGapSpacingValue-NoRow gap between children
columnGapSpacingValue-NoColumn gap between children
flexnumber-NoFlex value
alignenum-NoAlign items along the cross axis
justifyenum-NoJustify content along the main axis
bgstring-NoBackground color