Skip to main content
The Box component is the foundational layout primitive in Theme UI. It provides access to spacing utilities, colors, and the sx prop for theme-aware styling.

Import

Usage

Props

The Box component accepts all standard HTML div attributes plus the following:
React.ElementType
Render the component as a different HTML element or React component. Defaults to 'div'.
ThemeUIStyleObject
Theme-aware style object for applying CSS with access to theme values.
string
Apply a variant style from theme.variants. Use dot notation to access nested variants.

Spacing Props

Box includes shorthand props for margin and padding that map to theme space values:
ResponsiveValue<string | number>
Margin on all sides.
ResponsiveValue<string | number>
Margin top.
ResponsiveValue<string | number>
Margin right.
ResponsiveValue<string | number>
Margin bottom.
ResponsiveValue<string | number>
Margin left.
ResponsiveValue<string | number>
Margin left and right.
ResponsiveValue<string | number>
Margin top and bottom.
ResponsiveValue<string | number>
Padding on all sides.
ResponsiveValue<string | number>
Padding top.
ResponsiveValue<string | number>
Padding right.
ResponsiveValue<string | number>
Padding bottom.
ResponsiveValue<string | number>
Padding left.
ResponsiveValue<string | number>
Padding left and right.
ResponsiveValue<string | number>
Padding top and bottom.

Color Props

ResponsiveValue<string>
Text color from theme.colors.
ResponsiveValue<string>
Background color from theme.colors.
ResponsiveValue<number>
CSS opacity value.

Examples

Responsive Spacing

Color and Background

Custom Element