Box
The Box component is the most fundamental layout primitive. It’s a div element with support for system props and thesx prop for theme-aware styling.
Import
Usage
Props
React.ElementType
Render the Box as a different HTML element or component
string
Variant style from
theme.variantsThemeUIStyleObject
Theme-aware style object
Interpolation
Emotion css prop for additional styles
System Props
Box supports a wide range of system props for common CSS properties: Spacing:margin,m- marginmarginTop,mt- margin-topmarginRight,mr- margin-rightmarginBottom,mb- margin-bottommarginLeft,ml- margin-leftmarginX,mx- horizontal marginmarginY,my- vertical marginpadding,p- paddingpaddingTop,pt- padding-toppaddingRight,pr- padding-rightpaddingBottom,pb- padding-bottompaddingLeft,pl- padding-leftpaddingX,px- horizontal paddingpaddingY,py- vertical padding
color- text colorbackgroundColor,bg- background coloropacity- opacity
Examples
Basic Box
Responsive Spacing
As Different Element
Flex
The Flex component extends Box withdisplay: flex by default, making it easy to create flexbox layouts.
Import
Usage
Props
Flex accepts all Box props and automatically appliesdisplay: flex.
Examples
Horizontal Layout
Vertical Stack
Centered Content
Grid
The Grid component creates CSS Grid layouts with a simple API for defining columns and gaps.Import
Usage
Props
ResponsiveStyleValue<string | number>
Minimum width of child elements. Creates auto-fit or auto-fill grid columns.
ResponsiveStyleValue<string | number>
Number of columns to use for the layout. Cannot be used with
width prop.ResponsiveStyleValue<string | number>
default:"3"
Space between grid items (uses theme spacing scale)
'fit' | 'fill'
default:"'fit'"
Auto-repeat track behavior (auto-fit or auto-fill)
Examples
Responsive Columns
Fixed Width Columns
Custom Gap
Container
The Container component creates a centered layout with a maximum width, perfect for page content.Import
Usage
Props
Container accepts all Box props. It uses thecontainer variant from theme.layout by default.
string
default:"'container'"
Variant from
theme.layout