Skip to main content
Layout components are the foundational building blocks for structuring your UI. They provide flexible, theme-aware containers with powerful styling capabilities.

Box

The Box component is the most fundamental layout primitive. It’s a div element with support for system props and the sx 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.variants
ThemeUIStyleObject
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 - margin
  • marginTop, mt - margin-top
  • marginRight, mr - margin-right
  • marginBottom, mb - margin-bottom
  • marginLeft, ml - margin-left
  • marginX, mx - horizontal margin
  • marginY, my - vertical margin
  • padding, p - padding
  • paddingTop, pt - padding-top
  • paddingRight, pr - padding-right
  • paddingBottom, pb - padding-bottom
  • paddingLeft, pl - padding-left
  • paddingX, px - horizontal padding
  • paddingY, py - vertical padding
Color:
  • color - text color
  • backgroundColor, bg - background color
  • opacity - opacity

Examples

Basic Box

Responsive Spacing

As Different Element


Flex

The Flex component extends Box with display: flex by default, making it easy to create flexbox layouts.

Import

Usage

Props

Flex accepts all Box props and automatically applies display: 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)
Grid also accepts all Box props.

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 the container variant from theme.layout by default.
string
default:"'container'"
Variant from theme.layout

Default Styles

The Container component applies these default styles:

Examples

Basic Container

Custom Variant

Define variants in your theme:
Then use the variant:

Full-Width Sections