Skip to main content

Box

A generic container that provides a flexible alternative for custom designs not achievable with existing components. Use it to apply styling such as backgrounds, padding, or borders, or to nest and group other components. The contents of Box always maintain their natural size, making it especially useful within layout components that would otherwise stretch their children.

string

A label that describes the purpose or contents of the element. When set, it will be announced to users using assistive technologies and will provide them with more context.

Only use this when the element's content is not enough context for users using assistive technologies.

Default: 'generic'

Sets the semantic meaning of the component’s content. When set, the role will be used by assistive technologies to help users navigate the page.

Anchor to accessibilityVisibility
accessibilityVisibility
"visible" | "hidden" | "exclusive"
Default: 'visible'

Changes the visibility of the element.

  • visible: the element is visible to all users.
  • hidden: the element is removed from the accessibility tree but remains visible.
  • exclusive: the element is visually hidden but remains in the accessibility tree.
Default: 'transparent'

Adjust the background of the component.

Default: 'auto'

Adjust the block size.

Default: 'none' - equivalent to `none base auto`.

Set the border via the shorthand property.

This can be a size, optionally followed by a color, optionally followed by a style.

If the color is not specified, it will be base.

If the style is not specified, it will be auto.

Values can be overridden by borderWidth, borderStyle, and borderColor.

"" |
Default: '' - meaning no override

Adjust the color of the border.

<>
Default: 'none'

Adjust the radius of the border.

"" | <>
Default: '' - meaning no override

Adjust the style of the border.

"" | <"small" | "small-100" | "base" | "large" | "large-100" | "none">
Default: '' - meaning no override

Adjust the width of the border.

<"auto" | "none">
Default: 'auto'

Sets the outer display type of the component. The outer type sets a component's participation in flow layout.

  • auto the component's initial value. The actual value depends on the component and context.
  • none hides the component from display and removes it from the accessibility tree, making it invisible to screen readers.
Default: 'auto'

Adjust the inline size.

Default: 'none'

Adjust the maximum block size.

Default: 'none'

Adjust the maximum inline size.

Default: '0'

Adjust the minimum block size.

Default: '0'

Adjust the minimum inline size.

"visible" | "hidden"
Default: 'visible'

Sets the overflow behavior of the element.

  • hidden: clips the content when it is larger than the element’s container. The element will not be scrollable and the users will not be able to access the clipped content by dragging or using a scroll wheel on a mouse.
  • visible: the content that extends beyond the element’s container is visible.
<<>>
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.

padding also accepts a responsive value string with the supported PaddingKeyword as a query value.

<"" | <>>
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.

paddingBlock also accepts a responsive value string with the supported PaddingKeyword as a query value.

<"" | >
Default: '' - meaning no override

Adjust the block-end padding.

This overrides the block-end value of paddingBlock.

paddingBlockEnd also accepts a responsive value string with the supported PaddingKeyword as a query value.

<"" | >
Default: '' - meaning no override

Adjust the block-start padding.

This overrides the block-start value of paddingBlock.

paddingBlockStart also accepts a responsive value string with the supported PaddingKeyword as a query value.

<"" | <>>
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.

paddingInline also accepts a responsive value string with the supported PaddingKeyword as a query value.

<"" | >
Default: '' - meaning no override

Adjust the inline-end padding.

This overrides the inline-end value of paddingInline.

paddingInlineEnd also accepts a responsive value string with the supported PaddingKeyword as a query value.

<"" | >
Default: '' - meaning no override

Adjust the inline-start padding.

This overrides the inline-start value of paddingInline.

paddingInlineStart also accepts a responsive value string with the supported PaddingKeyword as a query value.

Was this section helpful?

HTMLElement

The content of the Box.

Was this section helpful?

Code

<>
<s-box padding="base">Available for iPad, iPhone, and Android.</s-box>

<s-box padding="base" background="subdued" border="base" borderRadius="base">
Available for iPad, iPhone, and Android.
</s-box>
</>

  • Creating custom designs when you can't build what you need with the existing components.
    • Setting up specific stylings such as background colors, paddings, and borders.
    • Nesting with other components.
Was this section helpful?

Component examples

Demonstrates creating a simple container with padding, base background, border, and rounded corners to group and highlight product information.

Illustrates using a box with responsive padding to create an adaptable container for shipping information that can adjust to different screen or container sizes.

Shows how to use boxes with ARIA roles and visibility controls to create semantic, screen-reader-friendly status and informational messages.

Demonstrates creating nested, hierarchical layouts using multiple boxes, showing how boxes can be combined to organize related content sections with different styling.

Was this section helpful?

Basic container

<s-box
padding="base"
background="base"
borderWidth="base"
borderColor="base"
borderRadius="base"
>
<s-paragraph>Product information</s-paragraph>
</s-box>