Stack

Visually combine components into a stack in ascending or descending order.

Kevin Dierkx

kevin@example.com

Isabella Duffey

isabella@example.com

James Black

james@example.com

Active team members

Usage

<x-stack>
    <x-card>...</x-card>
    <x-alert>...</x-alert>
    <x-card>...</x-card>
</x-stack>

Component API

Attribute Default Description
reverse false bool
Reverse the display order.

Reversing the stacking order

Components within a stack overlap based on the DOM order. By default this would result in the second element overlapping the first, the third element the second, and so on.

<x-stack>
    <x-alert style="success">First child in DOM</x-alert>
    <x-alert style="info">Second child in DOM</x-alert>
    <x-alert style="danger">Third child in DOM</x-alert>
</x-stack>

This can visually be reversed where each element is overlapped by the previous element in the DOM order by supplying the reverse attribute.

Note

Supplying the reverse attribute doesn't alter the DOM order, it only reverses the displayed order of the child elements.

<x-stack reverse>
    <x-alert style="success">First child in DOM</x-alert>
    <x-alert style="info">Second child in DOM</x-alert>
    <x-alert style="danger">Third child in DOM</x-alert>
</x-stack>

Supported components

The x-stack component is intended to be used with the x-card and x-alert components, but it's not limited to just those components.

When elements are added to the x-stack component, overlap is automatically accounted for by adding a spacer element using the ::before and ::after pseudo elements. Depending on the element this might conflict with existing flexbox styling. To resolve this you can simply wrap the element and move the flexbox styling one layer deeper.