Box
The Box component is the foundation of our layout system. It provides access to design tokens through the styling props.
Props
as
- Render as a different HTML element (default:div
)p
,pt
,pb
,pl
,pr
,px
,py
- Padding utilitiesm
,mt
,mb
,ml
,mr
,mx
,my
- Margin utilitiesdisplay
- CSS display propertyflexDirection
,justifyContent
,alignItems
,gap
- Flexbox utilitiesbackgroundColor
,color
,borderColor
- Color utilitiesborderRadius
,boxShadow
- Visual utilitiesstyle
- Additional CSS stylesminHeight
,minWidth
,maxHeight
,maxWidth
,height
,width
- Dimension utilities
Spacing
The Box component uses our spacing scale for padding and margin props:
Layout
Use Box for creating flexible layouts with flexbox:
Polymorphic Component
Box can render as any HTML element using the as
prop:
TypeScript
Box is fully typed with TypeScript, including support for the as
prop:
import { Box } from '@beauginbey/vanilla-components';
// Type-safe as prop
<Box as="button" onClick={() => {}} />
<Box as="a" href="/path" />
// Custom component
const CustomBox = (props: BoxProps<'div'>) => {
return <Box {...props} />;
};