API and Development
The Box component is the fundamental layout building block in our design system. It provides a flexible container that can be styled with various properties for spacing, borders, backgrounds, and more.
Simple box with padding and a background.
FlexBox accepts the same props as Box (it wraps Box with flex display by default). The table below applies to both. The only API difference is that FlexBox narrows display to flex or inline-flex; Box supports every Display value.
Name | Type | Default | Description |
|---|---|---|---|
|
| — | Controls cross-axis alignment of flex children. Maps to CSS |
|
| — | Removes bottom border-radius, making the box flush against the bottom edge. |
|
| — | Removes left border-radius, making the box flush against the left edge. |
|
| — | Removes right border-radius, making the box flush against the right edge. |
|
| — | Removes top border-radius, making the box flush against the top edge. |
|
| — | Applies a semantic background color token to the box. |
|
| — | Sets the initial main size of the flex item. Maps to CSS |
|
| — | Applies a border style to all sides of the box. |
|
| — | Applies a border style to only the bottom side. |
|
| — | Applies a border style to only the left side. |
|
| — | Sets the border radius using a design token. |
|
| — | Applies a border style to only the right side. |
|
| — | Applies a border style to only the top side. |
|
| — | Additional CSS class name(s) to apply to the box element. |
|
| — | Enables CSS container queries by setting the |
|
|
| Sets the CSS |
|
| — | Applies a box-shadow elevation level for depth/layering. |
|
| — | Sets the direction of the flex container's main axis. Maps to CSS |
|
| — | Controls whether flex items wrap onto multiple lines. Maps to CSS |
|
| — | Spacing between child elements. Maps to CSS |
|
| — | When true, sets |
|
| — | Controls main-axis alignment of flex children. Maps to CSS |
|
| — | Outer spacing around the box. Accepts a spacing token. |
|
| — | Click handler forwarded to the underlying element (along with other DOM props in |
|
| — | Keydown handler forwarded to the underlying element. Useful for div-based controls that need to respond to Enter/Space like a button. |
|
| — | Pointer down handler forwarded to the underlying element. |
|
| — | Controls overflow behavior for content that exceeds the box dimensions. |
|
| — | Inner spacing within the box. Accepts a spacing token. |
|
| — | Sets the CSS |
|
| — | React ref forwarded to the underlying |
|
|
| When true, sets |
|
| — | Inline styles applied directly to the box element. |
|
| — | Controls the CSS |
|
| — | Sets the CSS |
Box supports both block and flex layouts. Use display and flexDirection for flexbox layouts.
When using Flex you can also use an alias called FlexBox that adds display={Display.Flex} for you.
Box supports both margin and padding with a consistent spacing scale:
Box supports various positioning options.
Avoid nesting too many Box components. Consider using semantic HTML elements when possible and only use Box for styling purposes.
Use FlexBox for Layouts
FlexBox over Box display={Display.Flex} for flex layoutsgap prop for consistent spacing between flex itemsResponsive Design
grow and shrink for flexible layoutsPerformance
Accessibility