← Components

Containment · Material 3: Divider

Divider

Separates groups. In Minimal it's space by default; a faint tint line when a list needs a visible break.

Examples and variants

Space and tint

First divider is space, second is a tint.

Account

Billing

Danger zone

Example
function DividerBasic() {
  return (
    <div className="flex w-full max-w-sm flex-col text-sm">
      <p>Account</p>
      <Separator />
      <p>Billing</p>
      <Separator variant="tint" />
      <p>Danger zone</p>
    </div>
  )
}

Spec drawing

Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.

Install

With the CLI

The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.

Terminal
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/separator.json

By hand

No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.

  1. Install the packages it uses.

    Terminal
    npm install @base-ui/react cn
  2. Copy this file to the same paths in your project. Imports use the @/ alias for your project root.

    • components/ui/separator.tsxseparator
      components/ui/separator.tsx
      "use client"
      
      import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
      import { cn } from "cn"
      
      /*
        Divider. Minimal draws no lines:
        - variant="space" (default): an empty gap of --divider-space.
        - variant="tint": a faint --divider-thickness line in --divider-color,
          centred in the same gap, for dense lists that need a visible break.
      */
      function Separator({
        className,
        orientation = "horizontal",
        variant = "space",
        ...props
      }: SeparatorPrimitive.Props & { variant?: "space" | "tint" }) {
        return (
          <SeparatorPrimitive
            data-slot="separator"
            data-variant={variant}
            orientation={orientation}
            className={cn(
              "shrink-0 bg-clip-content data-horizontal:h-(--divider-space) data-horizontal:w-full data-vertical:w-(--divider-space) data-vertical:self-stretch",
              variant === "tint"
                ? "bg-(--divider-color) data-horizontal:py-[calc((var(--divider-space)-var(--divider-thickness))/2)] data-vertical:px-[calc((var(--divider-space)-var(--divider-thickness))/2)]"
                : "bg-transparent",
              className
            )}
            {...props}
          />
        )
      }
      
      export { Separator }
      

Imports

What the examples on this page import:

Imports
import { Separator } from "@/components/ui/separator"

Anatomy

  1. 1Divider · --divider-space; tint uses --divider-thickness and --divider-color.

Props

PropTypeDefaultDescription
variant"space" | "tint""space"Gap only, or a faint line.
orientation"horizontal" | "vertical""horizontal"Direction.

Tokens

Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.

TokenPoints toLightDark
--divider-thicknessvar(--stroke-width-thin)1pxsame
--divider-colorvar(--stroke-color-subtle)oklch(0.22 0.01 260 / 16%)oklch(1 0 0 / 8%)
--divider-spacevar(--space-gap-stack-lg)24pxsame

Motion

TriggerWhat happensTokens
NoneStatic.—

Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.

Accessibility

  • role=separator when it carries meaning.

Usage

Do

  • Prefer space.

Don’t

  • Don't draw lines between every row.

Code

components/ui/separator.tsx
"use client"

import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
import { cn } from "cn"

/*
  Divider. Minimal draws no lines:
  - variant="space" (default): an empty gap of --divider-space.
  - variant="tint": a faint --divider-thickness line in --divider-color,
    centred in the same gap, for dense lists that need a visible break.
*/
function Separator({
  className,
  orientation = "horizontal",
  variant = "space",
  ...props
}: SeparatorPrimitive.Props & { variant?: "space" | "tint" }) {
  return (
    <SeparatorPrimitive
      data-slot="separator"
      data-variant={variant}
      orientation={orientation}
      className={cn(
        "shrink-0 bg-clip-content data-horizontal:h-(--divider-space) data-horizontal:w-full data-vertical:w-(--divider-space) data-vertical:self-stretch",
        variant === "tint"
          ? "bg-(--divider-color) data-horizontal:py-[calc((var(--divider-space)-var(--divider-thickness))/2)] data-vertical:px-[calc((var(--divider-space)-var(--divider-thickness))/2)]"
          : "bg-transparent",
        className
      )}
      {...props}
    />
  )
}

export { Separator }