Skip to main content

Box

Foundation component. A View wrapper with shorthand style props, covers dimensions, flex, spacing, borders, colours, and position. Every other layout component in the library builds on top of Box.

Preview

import { Box } from '@devraj-labs/vajra-ui-core';

<Box w={220} p={16} bg="#2563EB" rounded={8} direction="row" align="center" gap={8}>
<Box w={24} h={24} bg="#ffffff" rounded={12} />
<Box w={24} h={24} bg="#ffffff" rounded={12} />
<Box w={24} h={24} bg="#ffffff" rounded={12} />
</Box>

Usage

import { Box } from '@devraj-labs/vajra-ui-core';

<Box w="100%" p={16} bg="#fff" rounded={8} direction="row" align="center" gap={8}>
{children}
</Box>

API

Dimensions

PropTypeMaps to
wDimensionValuewidth
hDimensionValueheight
minWDimensionValueminWidth
maxWDimensionValuemaxWidth
minHDimensionValueminHeight
maxHDimensionValuemaxHeight

Colours

PropTypeMaps to
bgstringbackgroundColor
borderColorstringborderColor

Borders

PropTypeMaps to
borderWidthnumberborderWidth
borderTopWidthnumberborderTopWidth
borderBottomWidthnumberborderBottomWidth
borderLeftWidthnumberborderLeftWidth
borderRightWidthnumberborderRightWidth
roundednumberborderRadius
roundedTnumberborderTopLeftRadius + borderTopRightRadius
roundedBnumberborderBottomLeftRadius + borderBottomRightRadius
roundedLnumberborderTopLeftRadius + borderBottomLeftRadius
roundedRnumberborderTopRightRadius + borderBottomRightRadius

Flex

PropTypeMaps to
flexnumberflex
gapnumbergap
justifyFlexStyle['justifyContent']justifyContent
alignFlexStyle['alignItems']alignItems
directionFlexStyle['flexDirection']flexDirection
wrapFlexStyle['flexWrap']flexWrap

Spacing

PropTypeMaps to
mnumbermargin
mxnumbermarginHorizontal
mynumbermarginVertical
mtnumbermarginTop
mbnumbermarginBottom
mlnumbermarginLeft
mrnumbermarginRight
pnumberpadding
pxnumberpaddingHorizontal
pynumberpaddingVertical
ptnumberpaddingTop
pbnumberpaddingBottom
plnumberpaddingLeft
prnumberpaddingRight

Position

PropTypeMaps to
position'absolute' | 'relative'position
topnumbertop
bottomnumberbottom
leftnumberleft
rightnumberright

Other

PropTypeDescription
styleViewStyle | ViewStyle[]Merged last, use for props not covered by shorthands (e.g. overflow)
childrenReact.ReactNodeChild elements

Also accepts all native ViewProps.

Example

Box example