Separator

A hairline between groups of content.

Set orientation="vertical" between items in a row; give the row a height.

Preview
basic.tsx
import { Separator } from "~/components/ui/separator"
import { Text } from "~/components/ui/text"

export default function Example() {
  return (
    <Text render={<div />} size="sm" className="w-full max-w-sm">
      <Text weight="medium">The Daily Brew</Text>
      <Text tone="muted">Weekend edition, 24 pages</Text>
      <Separator className="my-lg" />
      <div className="flex h-5 items-center gap-lg">
        <span>Pages</span>
        <Separator orientation="vertical" />
        <span>Setup</span>
        <Separator orientation="vertical" />
        <span>Ads</span>
      </div>
    </Text>
  )
}

Dependencies

What it's built from and what's built from it in Mocha, read from the imports in its source.

UsesNothing else in the system.
Used byNothing yet.
Packages @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20

Installation

Set the project up for Mocha once first, as Getting started shows. Then add it with the CLI, or by hand.

With the CLI

terminal
npx shadcn@latest add https://design.zepez.dev/r/mocha/separator.json

Manually

Install its packages:

terminal
npm install @ui-sdk/core@0.1.0-beta.20 @ui-sdk/react@0.1.0-beta.20

Then copy the source:

components/ui/separator.tsx
import { Separator as SeparatorPrimitive } from "@ui-sdk/react/separator"
import type * as React from "react"

import { cnState } from "~/lib/utils"

/** A soft line between groups of content, horizontal unless `orientation="vertical"`. */
function Separator({ className, ...props }: React.ComponentProps<typeof SeparatorPrimitive>) {
  return (
    <SeparatorPrimitive
      className={cnState(
        "shrink-0 rounded-full bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",
        className,
      )}
      {...props}
    />
  )
}

export { Separator }

API reference

Generated from Mocha's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.

Separator

A soft line between groups of content, horizontal unless orientation="vertical".

className

Type string | ((state: NoInfer<SeparatorState>) => string)

debug

Logs every state change with its reason to the console, in development builds.

Type boolean

decorative

Hides the separator from assistive technology with role="none", for a line that's only visual. Leave it off when the separator divides content a screen reader should hear as separate, like groups of menu items.

Type boolean · Default false

orientation

Which way the line runs. A vertical separator divides items in a row.

Type SeparatorOrientation · Default "horizontal"

render

Type RenderProp<NoInfer<SeparatorState>>

style

Type CSSProperties | ((state: NoInfer<SeparatorState>) => CSSProperties)