layout-switcher
A flexbox container that automatically switches from horizontal to vertical layout based on available space. Ideal for responsive layouts without media queries.
Attributes
| Attribute | Values | Default | Description |
|---|---|---|---|
data-layout-threshold |
20rem, 25rem, 30rem, 35rem, 40rem, 45rem |
30rem |
Container width at which layout switches from horizontal to vertical |
data-layout-gap |
none, xs, s, m, l, xl |
m |
Gap between items |
data-layout-limit |
2, 3, 4 |
- | Maximum items before forcing vertical layout |
data-layout-reverse |
boolean | - | Reverses order when stacked |
Basic Usage
Items display side-by-side when space allows, then stack vertically.
Item 1
Content that shares space horizontally when there's room.
Item 2
Stacks vertically when the container is narrow.
Code
Threshold Variants
The data-layout-threshold attribute controls when the switch happens.
Lower Threshold (20rem)
Stays horizontal longer, only stacks on very narrow containers.
Card A
Card B
Higher Threshold (40rem)
Switches to vertical layout earlier, at wider container widths.
Card A
Card B
Code
Item Limit
The data-layout-limit attribute forces vertical layout when there are more items than the limit.
Limit of 2
Item 1
Item 2
Item 3 (forces stack)
Code
Usage Examples
Form Actions
Card Header
Last updated 2 hours ago
Feature Comparison
$9/mo
- 5 Projects
- 10GB Storage
- Email Support
$29/mo
- Unlimited Projects
- 100GB Storage
- Priority Support
CSS Implementation
Related Elements
- layout-sidebar - Two-column layout with sidebar
- layout-grid - Auto-fit grid layout
- layout-cluster - Horizontal grouping with wrapping