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>
1
2
3
4
5
6

Props

Cols

NameTypePurpose
forcebooleanForce column layout even on mobile viewports.
reversedbooleanReverse the order of the columns in the document.
gap"none" | "sm" | "md" | "lg" | "xl"Gap between columns.

Cols.Col

NameTypePurpose
fitbooleanExclude 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.

1
2

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>
Filters
Results

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>
1
2
3
4
5
6

Gap size

Use the gap prop to set the space between columns. The fallback is md.

1
2
3
4
5
6
1
2
3
4
5
6
1
2
3
4
5
6
1
2
3
4
5
6
1
2
3
4
5
6