# vstack

> A vertical flex stack.

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

A vertical flex stack. Composes `u.flex()`, `u.flexCol()`, and — from
whichever option keys are given — `u.gap()`, `u.items()`, and
`u.justify()`.

## Quick reference

Every documented call, beside the CSS it emits.

| Call | CSS |
| --- | --- |
| `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:

```tsx
<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"`:

```tsx
<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:

```tsx
<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.

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

## Responsive design

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

```ts
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:

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

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

```ts
p(4)
```

## Signature

```ts
u.vstack(options?: StackOptions)
```
