sdxc

[ @sdxc/u/layout ]

vstack

A vertical flex stack.

import { vstack } from "@sdxc/u/layout";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.vstack({ gap: 4, align: "stretch" })css({ display: "flex", flexDirection: "column", gap: "calc(var(--ui-spacing, 0.25rem) * 4)", alignItems: "stretch" })

Examples

Basic example

Use vstack() to lay children out in a column, with the gap option setting the space between them:

01
02
03
<div mix={[vstack({ gap: 4 }), is(48), ...]}>
	<div mix={[...]}>01</div>
	<div mix={[...]}>02</div>
	<div mix={[...]}>03</div>
</div>

Aligning items

Use the align option to place items on the horizontal axis, like align: "center":

01
02
03
<div mix={[vstack({ gap: 4, align: "center" }), is(64), ...]}>
	<div mix={[is(20), ...]}>01</div>
	<div mix={[is(40), ...]}>02</div>
	<div mix={[is(28), ...]}>03</div>
</div>

Justifying items

Use the justify option to distribute items down the column, like justify: "between" to pin an action to the bottom of a card:

Weekly report
<div mix={[vstack({ justify: "between", align: "start" }), is(64), bs(40), ...]}>
	<span mix={[weight("semibold")]}>Weekly report</span>
	<button type="button" mix={[...]}>
		Download
	</button>
</div>

Applying on a state

Wrap the call in a state utility to scope it to one selector.

u.hover(u.vstack({ gap: 4, align: "stretch" }))

Responsive design

Wrap the call in a container query to scope it to one width.

u.at("md", u.vstack({ gap: 4, align: "stretch" }))

Customizing your theme

Customizing spacing

Every numeric step multiplies --ui-spacing, so redefining it rescales every spacing and sizing utility at once:

:root {
	--ui-spacing: 0.25rem;
}

Every call that names the step now reads the new value:

p(4)

Signature

u.vstack(options?: StackOptions)

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.