Skip to main content

Box

The Box component provides a container for layout and visual styling. Use it to apply padding, borders, and background colors, or to nest and group other components.

For user interaction, use Box in combination with interactive components like Button or Clickable. For scrollable content, use ScrollBox.

Use cases

  • Spacing control: Create consistent spacing and padding around content groups.
  • Structured layouts: Build layouts by nesting components within Box containers.
  • Responsive sizing: Apply sizing that adapts to different screen sizes and orientations.
  • Visual grouping: Group related interface elements with consistent boundaries.

Create layouts using a Box component. This example demonstrates a basic box container with padding and styling.

Create a container with a box

Create a container with a box

<s-box padding="base">
<s-text>View shipping settings</s-text>
</s-box>

Configure the following properties on the Box component.

Anchor to blockSize
blockSize
Default: 'auto'

Adjust the block size.

string

A unique identifier for the element.

Anchor to inlineSize
inlineSize
Default: 'auto'

Adjust the inline size.

Anchor to maxBlockSize
maxBlockSize
Default: 'none'

Adjust the maximum block size.

Anchor to maxInlineSize
maxInlineSize
Default: 'none'

Adjust the maximum inline size.

Anchor to minBlockSize
minBlockSize
Default: '0'

Adjust the minimum block size.

Anchor to minInlineSize
minInlineSize
Default: '0'

Adjust the minimum inline size.

Anchor to padding
padding
<>
Default: 'none'

Adjust the padding of all edges.

1-to-4-value syntax is supported. Note that, contrary to the CSS, it uses flow-relative values and the order is:

  • 4 values: block-start inline-end block-end inline-start
  • 3 values: block-start inline block-end
  • 2 values: block inline

For example:

  • large means block-start, inline-end, block-end and inline-start paddings are large.
  • large none means block-start and block-end paddings are large, inline-start and inline-end paddings are none.
  • large none large means block-start padding is large, inline-end padding is none, block-end padding is large and inline-start padding is none.
  • large none large small means block-start padding is large, inline-end padding is none, block-end padding is large and inline-start padding is small.

A padding value of auto will use the default padding for the closest container that has had its usual padding removed.

Anchor to paddingBlock
paddingBlock
"" | <>
Default: '' - meaning no override

Adjust the block-padding.

  • large none means block-start padding is large, block-end padding is none.

This overrides the block value of padding.

Anchor to paddingBlockEnd
paddingBlockEnd
"" |
Default: '' - meaning no override

Adjust the block-end padding.

This overrides the block-end value of paddingBlock.

Anchor to paddingBlockStart
paddingBlockStart
"" |
Default: '' - meaning no override

Adjust the block-start padding.

This overrides the block-start value of paddingBlock.

Anchor to paddingInline
paddingInline
"" | <>
Default: '' - meaning no override

Adjust the inline padding.

  • large none means inline-start padding is large, inline-end padding is none.

This overrides the inline value of padding.

Anchor to paddingInlineEnd
paddingInlineEnd
"" |
Default: '' - meaning no override

Adjust the inline-end padding.

This overrides the inline-end value of paddingInline.

Anchor to paddingInlineStart
paddingInlineStart
"" |
Default: '' - meaning no override

Adjust the inline-start padding.

This overrides the inline-start value of paddingInline.

  • Use semantic sizing: Choose auto to adapt to content, percentages for responsive layouts, pixels only for exact dimensions.
  • Use design system padding: Use predefined padding keywords (small, base, large) for consistency.
  • Use directional padding for asymmetry: Use paddingInline and paddingBlock when different spacing is needed on different sides.
  • Understand block vs inline: block refers to content flow direction (usually vertical), inline to text direction (usually horizontal).
Was this page helpful?