When to use
Section titled “When to use”Use Box to give content token-based padding, a surface, a border or rounded corners: a card, a panel, a well, a landmark. Use it when a layout needs a container and you do not want to write the values by hand.
When not to use
Section titled “When not to use”- To arrange items: Use Stack for vertical flow, Inline for horizontal flow and Grid for columns. Box is a single box only.
- For free styling: Box takes no
classNameorstyle. Stack, Inline and Grid takeclassNamefor layout; in Box every value is a token. - To limit the page width: Use Container to centre content and give it a maximum width.
Anatomy
Section titled “Anatomy”Box has two parts:
- Container: a single
<div>(or the element passed withrender). Padding, surface colour, border and corner radius are written to it as classes. - Content:
children. Box does not take part in the layout of its content; children sit in normal block flow.
Behaviour
Section titled “Behaviour”- Box is static: it does not change on hover, click or focus, and it is not in the tab order.
- A prop that is not set produces no class. With no props at all, no
classattribute is written. paddingInlineandpaddingBlockoverride thepaddingvalue on the same sides; they can be combined withpadding.background,borderandradiusdefault tonone; Box does not draw a visible surface by itself.
Guidelines
Section titled “Guidelines”Choose padding to fit the content
Section titled “Choose padding to fit the content”In a Box with a border, zero padding makes the text touch the border.
Card title
Card title
Choose the surface by its meaning
Section titled “Choose the surface by its meaning”raised is a card that stands above the page, sunken is an area set into it. Do not mix them up.
Card title
Card title
Content
Section titled “Content”- Box carries no text of its own; the content comes from its children.
- When you pass
render={<section aria-label="..." />}for a landmark, write a short name that does not appear elsewhere on the page. - Keep demo and example text neutral: “Card title”, “Card description goes here.”