Stack

Stack component is a layout component that stacks its children vertically or horizontally.

Examples Default stack

Default stack is using vertical direction with a gap of --dds-spacing-600 / 24px between its children.

<dap-ds-stack>
<dap-ds-button>Button 1</dap-ds-button>
<dap-ds-button>Button 2</dap-ds-button>
<dap-ds-button>Button 3</dap-ds-button>
</dap-ds-stack>
Horizontal stack

You can set the direction to row or row-reverse to stack the children horizontally. Horizontal stack is using the gap of --dds-spacing-200 / 8px between its children.

<dap-ds-stack direction="row">
<dap-ds-button>Button 1</dap-ds-button>
<dap-ds-button>Button 2</dap-ds-button>
<dap-ds-button>Button 3</dap-ds-button>
</dap-ds-stack>
Custom spacing

You can set the spacing to a custom value to adjust the space between the children. Any dds-spacing- variable number can be used.

<dap-ds-stack direction="row" spacing="600">
<dap-ds-button>Button 1</dap-ds-button>
<dap-ds-button>Button 2</dap-ds-button>
<dap-ds-button>Button 3</dap-ds-button>
</dap-ds-stack>
Start margin and end margin

You can add margin to the start or end of the stack by setting the startMargin or endMargin to true.

<dap-ds-stack direction="row" style={{ backgroundColor: 'var(--dds-background-neutral-stronger)' }}>
<dap-ds-stack spacing="600" startMargin>
  <dap-ds-button>Button 1</dap-ds-button>
  <dap-ds-button>Button 2</dap-ds-button>
  <dap-ds-button>Button 3</dap-ds-button>
</dap-ds-stack>
<dap-ds-stack spacing="600" endMargin>
  <dap-ds-button>Button 1</dap-ds-button>
  <dap-ds-button>Button 2</dap-ds-button>
  <dap-ds-button>Button 3</dap-ds-button>
</dap-ds-stack>
</dap-ds-stack>
Importing
import { DapDSStack } from 'dap-design-system'
Importing React
import { DapDSStackReact } from 'dap-design-system/react'
Tree-Shakeable Imports

For optimal bundle sizes, use the tree-shakeable import syntax:

import { DapDSStack } from 'dap-design-system/components'
Attributes
PropertyTypeDefaultDescription
direction'column', 'column-reverse' , 'row' , 'row-reverse''column'The direction of the stack.
endMarginboolean, undefinedfalseAdds margin to the end of the stack.
startMarginboolean, undefinedfalseAdds margin to the start of the stack.
spacingThe spacing of the stack. Uses the system spacing scale (100, 200, 300...etc)
Slots
NameDescription
(default)The content of the stack.
Events

No custom events available.

CSS Parts
Part NameDescription
stackThe main stack container.
How to Use CSS Parts

You can style CSS parts using the ::part() pseudo-element selector:

/* Target a specific part */
.my-custom-dap-ds-stack::part(stack) {
  /* Your custom styles */
}

Example usage:

<dap-ds-stack class="my-custom-dap-ds-stack">
  Stack
</dap-ds-stack>
.my-custom-dap-ds-stack::part(stack) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.

CSS Custom Properties

No CSS custom properties available.