Skip to main content

Box

The foundational layout primitive. Every other layout component (Row, Col, Center, Grid, ...) is built on top of Box.

<Box bg="surface" p="s-4" rounded="r-3" borderWidth={1} borderColor="border">
<Box bg="primary" w={40} h={40} rounded="r-2" />
</Box>

Props

PropTypeDefaultDescription
bgTVajraColorsBackground color token.
borderColorTVajraColorsBorder color token.
borderWidth / borderTopWidth / borderBottomWidth / borderLeftWidth / borderRightWidthnumberRaw border widths.
rounded / roundedT / roundedB / roundedL / roundedRTRoundedTokenCorner radius token.
w / h / minW / maxW / minH / maxHDimensionValueRaw dimension values (no token).
flexnumberFlex grow/shrink shorthand.
justifyViewStyle['justifyContent']Maps to justifyContent.
alignViewStyle['alignItems']Maps to alignItems.
directionViewStyle['flexDirection']Maps to flexDirection.
wrapViewStyle['flexWrap']Maps to flexWrap.
positionViewStyle['position']'relative' | 'absolute'.
top / bottom / left / rightDimensionValueOffsets, used with position.
overflowViewStyle['overflow']Overflow behavior.
opacitynumberOpacity.
m / mx / my / mt / mb / ml / mrTSpacingTokenMargin tokens.
p / px / py / pt / pb / pl / prTSpacingTokenPadding tokens.
gapTSpacingTokenGap token.
styleViewStyle | ViewStyle[]Extra style, merged in.

Also accepts all standard React Native ViewProps (except style, which is typed above).