# Separator

> A line between groups, across or down, with a word in it such as or, a day or New.

Page: https://uicontext.com/docs/components/separator

Group: Primitives.

## When to use

A line between groups, across or down, with a word in it such as or, a day or New. Use [Form Layout](https://uicontext.com/docs/components/form-layout.md) instead when you are laying out a form's sections.

## Usage

```ts
import { Separator } from "./ui/uicontext/components/Separator.ts"

export const Or = <M>(h: Html.H<M>) => Separator(h, { label: "or" })
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### Between two ways in

The example the page opens with: Separator in “Between two ways in”.

This example also uses Domain. Install it too:

```sh
npx shadcn@latest add checkfu/uicontext/button-family
```

```ts title="src/demo.ts" source="www/src/examples/separator/demo.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { buttonStyle } from "./ui/uicontext/components/Button.ts"
import { Separator } from "./ui/uicontext/components/Separator.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { space } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({
	card: { display: "grid", gap: space.lg, inlineSize: "min(100%, 22rem)" },
	wide: { inlineSize: "100%", justifyContent: "center" },
})

// a sign-in card: two ways in, with "or" between them
export const SignInChoices = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.card)).children(
		h.button.attrs({ type: "button", ...sx(...buttonStyle({ size: "lg" }), styles.wide) }).children("Continue with a passkey"),
		Separator(h, { label: "or" }),
		h.button.attrs({ type: "button", ...sx(...buttonStyle({ tone: "primary", size: "lg" }), styles.wide) }).children("Continue with email"),
	)
```

### Days and unread in a thread

`align: "start"` and `tone: "accent"` for a New line. A `decorative` vertical one only draws.

```ts title="src/messages.ts" source="www/src/examples/separator/messages.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Separator } from "./ui/uicontext/components/Separator.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({
	wrap: { display: "grid", gap: space.md, inlineSize: "min(100%, 30rem)" },
	message: { margin: 0, fontSize: font.sm, color: color.fg, lineHeight: 1.5 },
	who: { fontWeight: 600, marginInlineEnd: space.sm },
	footer: { display: "flex", alignItems: "center", gap: space.md, fontSize: font.sm, color: color.muted },
})

const line = <M>(h: Html.H<M>, who: string, text: string) => h.p.attrs(sx(styles.message)).children(h.span.attrs(sx(styles.who)).children(who), text)

// a thread: the day, then "New" above what you haven't read; and a vertical line in a footer row
export const ThreadDividers = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.wrap)).children(
		Separator(h, { label: "Yesterday" }),
		line(h, "Priya", "Pushed the pricing page copy. Can someone check the annual toggle?"),
		line(h, "Kenji", "Looks right on mobile. Merging after lunch."),
		Separator(h, { label: "Today" }),
		line(h, "Ada", "Merged. Deploy is going out now."),
		Separator(h, { label: "New", align: "start", tone: "accent" }),
		line(h, "Tomas", "Annual prices show monthly in the receipt email."),
		line(h, "Priya", "On it."),
		h.div.attrs(sx(styles.footer)).children("12 replies", Separator(h, { orientation: "vertical", decorative: true }), "3 people", Separator(h, { orientation: "vertical", decorative: true }), "Last reply 4 min ago"),
	)
```

## API reference

**Options**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `orientation` | `"horizontal" \| "vertical"` | — | — |
| `label` | `string` | — | Words on the line: "or", "Today", "New". |
| `align` | `"center" \| "start"` | `center` | Where the words sit; `center` by default. |
| `tone` | `"accent"` | — | The line in the danger color, for "New" above unread messages. |
| `spaced` | `boolean` | — | Room above and below (or beside, when vertical). |
| `decorative` | `boolean` | — | Only draws a line: no role for a screen reader. |
| `style` | `Style` | — | — |

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/separator
```

With npm: `npx shadcn@latest add checkfu/uicontext/separator`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/separator`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/separator`.

It writes these files:

- `src/ui/uicontext/components/Separator.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/Separator.ts](https://github.com/checkfu/uicontext/blob/main/src/Separator.ts)

## Related

- [Button](https://uicontext.com/docs/components/button.md) (`button`): A button, and a link that looks like one, in every tone and three sizes.
- [Toggle](https://uicontext.com/docs/components/toggle.md) (`toggle`): A button that stays pressed, such as Bold or Pin.
- [Toggle Group](https://uicontext.com/docs/components/toggle-group.md) (`toggle-group`): Buttons that stay pressed and share one value, such as text styles.
- [Input](https://uicontext.com/docs/components/input.md) (`input`): Text inputs, selects and textareas in a labeled field with a hint and an error, and their styles for controls you lay out yourself.
- [Status](https://uicontext.com/docs/components/status.md) (`status`): Status badges and tags for runs and records.
- [Glyphs](https://uicontext.com/docs/components/glyphs.md) (`glyphs`): Small marks for status, priority, color and people.
