Box
The Box component is a utility wrapper that provides access to all system properties through props. It’s the most fundamental layout primitive in Material UI.Basic usage
System props
Box accepts all system properties as props, allowing you to quickly style components without creating custom styled components.Spacing
Display and layout
Color and backgrounds
Component prop
Change the rendered element using thecomponent prop:
The sx prop
Thesx prop provides a shortcut for defining custom styles with access to the theme:
Responsive values
Props
BoxProps
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | The content of the component |
component | React.ElementType | 'div' | The component used for the root node |
sx | SxProps<Theme> | - | System prop for defining custom styles |
System props
Box supports all system properties from the following categories: Borders:border, borderTop, borderRight, borderBottom, borderLeft, borderColor, borderRadius
Display: display, displayPrint, overflow, textOverflow, visibility, whiteSpace
Flexbox: flexDirection, flexWrap, justifyContent, alignItems, alignContent, order, flex, flexGrow, flexShrink, alignSelf
Grid: gap, columnGap, rowGap, gridColumn, gridRow, gridAutoFlow, gridAutoColumns, gridAutoRows, gridTemplateColumns, gridTemplateRows, gridTemplateAreas, gridArea
Palette: color, bgcolor, backgroundColor
Positions: position, zIndex, top, right, bottom, left
Shadows: boxShadow
Sizing: width, maxWidth, minWidth, height, maxHeight, minHeight, boxSizing
Spacing: m, mt, mr, mb, ml, mx, my, p, pt, pr, pb, pl, px, py, margin, marginTop, marginRight, marginBottom, marginLeft, padding, paddingTop, paddingRight, paddingBottom, paddingLeft
Typography: fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign, textTransform