Stripe | Financial Infrastructure to Grow Your Revenue

Stripe | Financial Infrastructure to Grow Your Revenue

5282 articles

Box component for Stripe Apps


Box component for Stripe Apps

Use boxes to wrap other components and add custom styles and layouts.

SDK version

To add the Box component to your app:

Boxes are block-level elements, equivalent to a div HTML element. They support custom styles. If you want to render or style inline elements, see the Inline component.

Loading example...

<Box
 css={{
 padding: 'xxlarge',
 color: 'secondary',
 backgroundColor: 'container',
 borderRadius: 'small',
 }}
>
 This is a box.
</Box>

Box props

PropertyType
childrenRequired React.ReactNode The contents of the component.
cssOptional CSS | undefined Related types: CSS.

CSS

PropertyType
alignSelfXOptional ("start" | "center" | "end" | "stretch") | undefined Horizontal alignment. See Layout properties for details.
alignSelfYOptional ("top" | "center" | "baseline" | "bottom" | "stretch") | undefined Vertical alignment. See Layout properties for details.
alignXOptional ("start" | "center" | "end" | "stretch") | undefined Horizontal alignment. See Layout properties for details.
alignYOptional ("top" | "center" | "baseline" | "bottom" | "stretch") | undefined Vertical alignment. See Layout properties for details.
backgroundColorOptional ("container" | "surface") | undefined
bleedOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
bleedBottomOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
bleedLeftOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
bleedRightOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
bleedTopOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
bleedXOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
bleedYOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
borderBottomColorOptional ("neutral" | "critical") | undefined
borderBottomLeftRadiusOptional ("none" | "xsmall" | "small" | "medium" | "large" | "rounded") | undefined
borderBottomRightRadiusOptional ("none" | "xsmall" | "small" | "medium" | "large" | "rounded") | undefined
borderBottomStyleOptional ("dashed" | "dotted" | "double" | "groove" | "hidden" | "inherit" | "initial" | "inset" | "none" | "outset" | "revert-layer" | "revert" | "ridge" | "solid" | "unset") | undefined
borderBottomWidthOptional number | undefined The width of the border.
borderColorOptional ("neutral" | "critical") | undefined
borderLeftColorOptional ("neutral" | "critical") | undefined
borderLeftStyleOptional ("dashed" | "dotted" | "double" | "groove" | "hidden" | "inherit" | "initial" | "inset" | "none" | "outset" | "revert-layer" | "revert" | "ridge" | "solid" | "unset") | undefined
borderLeftWidthOptional number | undefined The width of the border.
borderRadiusOptional ("none" | "xsmall" | "small" | "medium" | "large" | "rounded") | undefined
borderRightColorOptional ("neutral" | "critical") | undefined
borderRightStyleOptional ("dashed" | "dotted" | "double" | "groove" | "hidden" | "inherit" | "initial" | "inset" | "none" | "outset" | "revert-layer" | "revert" | "ridge" | "solid" | "unset") | undefined
borderRightWidthOptional number | undefined The width of the border.
borderStyleOptional ("dashed" | "dotted" | "double" | "groove" | "hidden" | "inherit" | "initial" | "inset" | "none" | "outset" | "revert-layer" | "revert" | "ridge" | "solid" | "unset") | undefined
borderTopColorOptional ("neutral" | "critical") | undefined
borderTopLeftRadiusOptional ("none" | "xsmall" | "small" | "medium" | "large" | "rounded") | undefined
borderTopRightRadiusOptional ("none" | "xsmall" | "small" | "medium" | "large" | "rounded") | undefined
borderTopStyleOptional ("dashed" | "dotted" | "double" | "groove" | "hidden" | "inherit" | "initial" | "inset" | "none" | "outset" | "revert-layer" | "revert" | "ridge" | "solid" | "unset") | undefined
borderTopWidthOptional number | undefined The width of the border.
borderWidthOptional number | undefined The width of the border.
bottomOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
boxShadowOptional ("none" | "base" | "top" | "hover" | "focus") | undefined
colorOptional ("brand" | "primary" | "secondary" | "disabled" | "info" | "success" | "attention" | "critical") | undefined
columnGapOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
displayOptional "grid" | undefined
distributeOptional ("packed" | "space-between") | undefined
fillOptional ("brand" | "primary" | "secondary" | "disabled" | "info" | "success" | "attention" | "critical") | undefined
focusRingOptional ("none" | "base" | "top" | "hover" | "focus") | undefined
fontOptional ("body" | "bodyEmphasized" | "caption" | "heading" | "kicker" | "lead" | "subheading" | "subtitle" | "title") | undefined
fontFamilyOptional ("monospace" | "ui") | undefined
fontWeightOptional ("regular" | "semibold" | "bold") | undefined
gapOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
gapXOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
gapYOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
gridColumnsOptional number | undefined
heightOptional (number | "auto" | "fill" | "min" | "max" | "fit" | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | "5/12" | "6/12" | "7/12" | "8/12" | "9/12" | "10/12" | "11/12") | undefined The height of the component. See Sizing for details.
insetOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
keylineOptional ("neutral" | "critical") | undefined
leftOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
marginOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
marginBottomOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
marginLeftOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
marginRightOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
marginTopOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
marginXOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
marginYOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
maxHeightOptional (number | "auto" | "fill" | "min" | "max" | "fit" | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | "5/12" | "6/12" | "7/12" | "8/12" | "9/12" | "10/12" | "11/12") | undefined The height of the component. See Sizing for details.
maxWidthOptional (number | "auto" | "fill" | "min" | "max" | "fit" | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | "5/12" | "6/12" | "7/12" | "8/12" | "9/12" | "10/12" | "11/12") | undefined The width of the component. See Sizing for details.
minHeightOptional (number | "auto" | "fill" | "min" | "max" | "fit" | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | "5/12" | "6/12" | "7/12" | "8/12" | "9/12" | "10/12" | "11/12") | undefined The height of the component. See Sizing for details.
minTileWidthOptional (number | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | "5/12" | "6/12" | "7/12" | "8/12" | "9/12" | "10/12" | "11/12") | undefined
minWidthOptional (number | "auto" | "fill" | "min" | "max" | "fit" | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | "5/12" | "6/12" | "7/12" | "8/12" | "9/12" | "10/12" | "11/12") | undefined The width of the component. See Sizing for details.
overflowOptional ("visible" | "hidden" | "clip" | "scroll" | "auto") | undefined
overflowWrapOptional ("break-word" | "normal") | undefined
overflowXOptional ("visible" | "hidden" | "clip" | "scroll" | "auto") | undefined
overflowYOptional ("visible" | "hidden" | "clip" | "scroll" | "auto") | undefined
paddingOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
paddingBottomOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
paddingLeftOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
paddingRightOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
paddingTopOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
paddingXOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
paddingYOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
rowGapOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
stackOptional ("x" | "y" | "z") | undefined
textAlignOptional ("center" | "end" | "justify" | "left" | "match-parent" | "right" | "start") | undefined
textOverflowOptional "ellipsis" | undefined
textTransformOptional ("capitalize" | "uppercase" | "lowercase" | "none" | "full-width" | "full-size-kana") | undefined
topOptional (number | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge") | undefined
topShadowOptional ("none" | "base" | "top" | "hover" | "focus") | undefined
whiteSpaceOptional ("normal" | "nowrap" | "pre" | "pre-wrap" | "pre-line" | "break-spaces") | undefined
widthOptional (number | "auto" | "fill" | "min" | "max" | "fit" | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | "5/12" | "6/12" | "7/12" | "8/12" | "9/12" | "10/12" | "11/12") | undefined The width of the component. See Sizing for details.
wordBreakOptional ("normal" | "break-all" | "keep-all" | "break-word") | undefined
wordWrapOptional ("break-word" | "normal") | undefined
wrapOptional ("wrap" | "nowrap" | "wrap-reverse") | undefined
zIndexOptional ("overlay" | "partial") | undefined
backgroundOptional Deprecated Use the backgroundColor property instead. ("container" | "surface") | undefined
isolatedDependenciesOptional Deprecated string[] | undefined
layoutOptional Deprecated Use the stack property instead. ("column" | "inline" | "row" | "inline-column" | "inline-row") | undefined
whenOptional Deprecated Use nested styles instead. (string | { pointer: "none" | "coarse" | "fine"; colorScheme: "dark" | "light"; motion: "supported" | "reduced"; hover: "none" | "hover"; viewportWidth: "small" | "medium" | "large" | "xlarge"; contrast: "more" | "less"; }[] | { pointer: "none" | "coarse" | "fine"; colorScheme: "dark" | "light"; motion: "supported" | "reduced"; hover: "none" | "hover"; viewportWidth: "small" | "medium" | "large" | "xlarge"; contrast: "more" | "less"; }) | undefined

Nesting boxes

For some components, you can use a Box to manage the layout and spacing of their children. For example, nest a Box inside an AccordionItem to add padding:

Loading example...

<Box css={{backgroundColor: 'surface'}}>
 <Accordion>
 <AccordionItem title="Apples">
 <Box css={{padding: 'xlarge'}}>Accordion contents</Box>
 </AccordionItem>
 <AccordionItem title="Bananas">
 <Box css={{padding: 'xlarge'}}>Accordion contents</Box>
 </AccordionItem>
 <AccordionItem title="Peaches" subtitle="A subtitle can be provided">
 <Box css={{padding: 'xlarge'}}>Accordion contents</Box>
 </AccordionItem>
 </Accordion>
</Box>

Custom CSS

The Box component supports custom styles. This example demonstrates usage of the boxShadow property.

Loading example...

<Box css={{stack: 'y', gap: 'large'}}>
 {['boxShadow', 'topShadow', 'focusRing'].map((shadowProp) => {
 return (
 <Box css={{stack: 'y', gap: 'medium'}} key={shadowProp}>
 <Box css={{font: 'heading', fontFamily: 'monospace'}}>
 {shadowProp}
 </Box>
 {['base', 'hover', 'focus', 'top'].map((shadowValue) => (
 <Box key={[shadowProp, shadowValue].join('-')}>
 <Box
 css={{
 font: 'body',
 padding: 'large',
 fontFamily: 'monospace',
 [shadowProp]: shadowValue,
 }}
 >
 {shadowProp}={shadowValue}
 </Box>
 </Box>
 ))}
 </Box>
 );
 })}
</Box>

See also

Last verified 2026-09-25

Is this helpful?