Skip to Content
DocumentationLayoutBox

Box

A versatile layout primitive that serves as the foundation for building UI. Box provides comprehensive styling props for spacing, colors, borders, positioning, and more. Use it to wrap and position other components, create cards, or build custom layouts.

I am a box.

With properties

I am a box.

Responsive sizing

Use Tailwind preset values for width and height with responsive breakpoints. Resize your browser window to see this box change width: full width on mobile, half width on medium screens, and one-third on large screens.

Responsive width

State styles

Apply styles for hover, focus, and active states using object props. Each state accepts color, backgroundColor, borderColor, and opacity.

Hover over me

Multiple states

Click to focus, then hover and click to see all states.

Interactive box (hover, focus, active)

Component props

NameTypeValues
displayResponsive<Display>"none" | "inline" | "inline-block" | "block"
positionResponsive<Position>"static" | "relative" | "absolute" | "fixed" | "sticky"
colorFontColorSemanticColor | ColorName | TailwindColor
backgroundColorBackgroundColorSemanticColor | SurfaceColor | ColorName | TailwindColor
fontSizeResponsive<FontSize>"xs" | "sm" | "base" | "lg" | "xl" | "2xl" | ... | "9xl"
fontWeightResponsive<FontWeight>"thin" | "light" | "normal" | "medium" | "semibold" | "bold" | ...
textAlignResponsive<TextAlign>"left" | "center" | "right"
borderResponsive<Border>true | "top" | "right" | "bottom" | "left" | "none"
borderColorBorderColorSemanticColor | ColorName | TailwindColor
borderWidthResponsive<BorderWidth>"sm" | "md" | "lg" | "xl"
borderRadiusResponsive<BorderRadius>true | "none" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full"
shadowResponsive<BoxShadow>true | "none" | "sm" | "md" | "lg" | "xl" | "2xl" | "inner"
paddingResponsive<Padding>true | Spacing
paddingXResponsive<Padding>true | Spacing
paddingYResponsive<Padding>true | Spacing
paddingTopResponsive<Padding>Spacing
paddingRightResponsive<Padding>Spacing
paddingBottomResponsive<Padding>Spacing
paddingLeftResponsive<Padding>Spacing
marginResponsive<Spacing>"0" | "1" | "2" | "3" | "4" | ... or negative
marginXResponsive<Spacing>Spacing
marginYResponsive<Spacing>Spacing
marginTopResponsive<Spacing>Spacing
marginRightResponsive<Spacing>Spacing
marginBottomResponsive<Spacing>Spacing
marginLeftResponsive<Spacing>Spacing
widthResponsive<Width | string>Spacing | Fraction | "auto" | "full" | "screen" | "min" | "max" | "fit" | custom CSS
minWidthResponsive<MinWidth | string>Spacing | "full" | "min" | "max" | "fit" | custom CSS
maxWidthResponsive<MaxWidth | string>Spacing | "none" | "xs"-"7xl" | "full" | "prose" | "screen-*" | custom CSS
heightResponsive<Height | string>Spacing | Fraction | "auto" | "full" | "screen" | "min" | "max" | "fit" | custom CSS
minHeightResponsive<MinHeight | string>Spacing | "full" | "screen" | "min" | "max" | "fit" | custom CSS
maxHeightResponsive<MaxHeight | string>Spacing | "none" | "full" | "screen" | "min" | "max" | "fit" | custom CSS
topstringCSS value (inline style)
rightstringCSS value (inline style)
bottomstringCSS value (inline style)
leftstringCSS value (inline style)
overflowResponsive<Overflow>"visible" | "hidden" | "clip" | "scroll" | "auto"
overflowXResponsive<Overflow>"visible" | "hidden" | "clip" | "scroll" | "auto"
overflowYResponsive<Overflow>"visible" | "hidden" | "clip" | "scroll" | "auto"
cursorResponsive<Cursor>"auto" | "default" | "pointer" | "wait" | "text" | "move" | "not-allowed" | ...
opacityResponsive<Opacity>"0" | "5" | "10" | "15" | ... | "95" | "100"
pointerEventsResponsive<PointerEvents>"none" | "auto"
alignSelfResponsive<AlignSelf>"center" | "start" | "end" | "stretch" | "baseline" | ...
justifySelfResponsive<JustifySelf>"center" | "start" | "end" | "stretch" | ...
flexBasisstringCSS value (inline style)
flexGrowstring | numberInline style
flexShrinkstring | numberInline style
gridAreastringCSS value (inline style)
gridRowstringCSS value (inline style)
gridColumnstringCSS value (inline style)
ordernumberInline style
zIndexnumberInline style
hoverStateStyles{ color?, backgroundColor?, borderColor?, opacity? }
focusStateStyles{ color?, backgroundColor?, borderColor?, opacity? }
activeStateStyles{ color?, backgroundColor?, borderColor?, opacity? }
asstringHTML element to render
renderRenderPropRender prop for polymorphism