A line between groups, across or down, with a word in it such as or, a day or New.
- 0.9 kB JS 2.5 kB CSS gzipped
- No serious axe issues
- Server-rendered, hydrates
- 44px touch targets
- Right-to-left
- 9 tests
or
This example also uses Domain. Install it too:
npx shadcn@latest add checkfu/uicontext/button-familyimport 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 themexport 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"), )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 instead when you are laying out a form's sections.
Usage
import { Separator } from "./ui/uicontext/components/Separator.ts"export const Or = <M>(h: Html.H<M>) => Separator(h, { label: "or" })Examples
Days and unread in a thread
align: "start" and tone: "accent" for a New line. A decorative vertical one only draws.
Yesterday
PriyaPushed the pricing page copy. Can someone check the annual toggle?
KenjiLooks right on mobile. Merging after lunch.
Today
AdaMerged. Deploy is going out now.
New
TomasAnnual prices show monthly in the receipt email.
PriyaOn it.
12 replies3 peopleLast reply 4 min ago
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 rowexport 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
pnpm dlx shadcn@latest add checkfu/uicontext/separator