Cols
Split multiple HTML nodes in columns.
Each direct child gets its own column, and every column takes a proportional share of the available width by default. On mobile, the elements stack vertically.
Use Cols to present multiple items distributed by column, such as a side-by-side comparison. Use
Stack when you need items to wrap or want precise positioning.
Usage
Group the elements in a Cols component.
<script>
import { Cols } from "@makigas/genshi-svelte";
</script>
<Cols>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</Cols>
Props
Cols
| Name | Type | Purpose |
|---|---|---|
force | boolean | Force column layout even on mobile viewports. |
reversed | boolean | Reverse the order of the columns in the document. |
gap | "none" | "sm" | "md" | "lg" | "xl" | Gap between columns. |
Cols.Col
| Name | Type | Purpose |
|---|---|---|
fit | boolean | Exclude this column from having a proportional width. |
Force columns
Cols are rendered as a vertical stack on mobile, where space is limited. Add the force prop to
keep columns side by side at any viewport width.
<Cols force>
<div>1</div>
<div>2</div>
</Cols>
Resize the window to see the columns stay side by side at a narrow viewport width.
Fit element
Use <Cols.Col fit> as a direct child to opt it out of taking a proportional width. Combine it with
other props to create layouts such as sidebars.
<Cols>
<Cols.Col fit>Filters</Cols.Col>
<div>Results</div>
</Cols>
Reverse
Add the reversed prop to reverse the visual order when columns are side by side. Use it with
force to reverse the columns at any viewport width. The vertical layout keeps the source order.
<Cols reversed>
<div>1</div>
<div>2</div>
</Cols>
Gap size
Use the gap prop to set the space between columns. The fallback is md.