# hstack

> A horizontal flex stack.

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

A horizontal flex stack. Composes `u.flex()`, `u.flexRow()`, 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.hstack({ gap: 4, align: "center", justify: "between" })` | `css({ display: "flex", flexDirection: "row", gap: "calc(var(--ui-spacing, 0.25rem) * 4)", alignItems: "center", justifyContent: "space-between" })` |

## Examples

### Basic example

Use `hstack()` to lay children out in a row, with the `gap` option setting the space between them:

```tsx
<div mix={[hstack({ gap: 4 }), ...]}>
	<div mix={[...]}>01</div>
	<div mix={[...]}>02</div>
	<div mix={[...]}>03</div>
</div>
```

### Aligning items

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

```tsx
<div mix={[hstack({ gap: 4, align: "center" }), ...]}>
	<div mix={[bs(12), ...]}>01</div>
	<div mix={[bs(24), ...]}>02</div>
	<div mix={[bs(16), ...]}>03</div>
</div>
```

### Justifying items

Use the `justify` option to distribute items along the row, like `justify: "between"` for a toolbar:

```tsx
<div mix={[hstack({ align: "center", justify: "between" }), ...]}>
	<span mix={[weight("semibold")]}>Inbox</span>
	<div mix={[hstack({ gap: 2 })]}>
		<button type="button" mix={[...]}>
			Archive
		</button>
		<button type="button" mix={[...]}>
			Reply
		</button>
	</div>
</div>
```

## Applying on a state

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

```ts
u.hover(u.hstack({ gap: 4, align: "center", justify: "between" }))
```

## Responsive design

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

```ts
u.at("md", u.hstack({ gap: 4, align: "center", justify: "between" }))
```

## 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.hstack(options?: StackOptions)
```
