# Separator

import { Callout } from "fumadocs-ui/components/callout";
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import { Step, Steps } from "fumadocs-ui/components/steps";
import { Tabs, Tab } from "fumadocs-ui/components/tabs";
import {
  Badge,
  Card,
  CardContent,
  CardHeader,
  CardTitle,
  Separator,
} from "@pycolors/ui";
import {
  ArrowRight,
  Columns3,
  LayoutList,
  LayoutTemplate,
  ListTree,
  Minus,
  Palette,
  PanelsTopLeft,
  PanelTop,
  Rows3,
  SplitSquareVertical,
  Tags,
  XCircle,
  CheckCircle,
} from "lucide-react";
import { PreferAvoid } from "@/components/docs/prefer-avoid";
import { DocsLinks } from "@/components/docs/docs-links";
import { DocsFeatureGrid } from "@/components/docs/docs-feature-grid";

<div className="flex flex-wrap items-center gap-2">
  <Badge variant="outline">
    UI
  </Badge>

  <Badge>
    Separator
  </Badge>
</div>

### Visual separation without visual noise

The **Separator** component creates a thin divider between related pieces of interface.

Use it for:

* separating page sections
* grouping card content
* dividing toolbar actions
* separating metadata rows
* creating vertical dividers in compact layouts
* improving scanability without adding heavy containers

Separator is intentionally minimal. It uses PyColors semantic tokens such as `bg-border`, so it adapts to light mode, dark mode, and product theme overrides.

<Callout title="Core idea">
  Separator should clarify structure, not decorate the page.
</Callout>

### Import

```tsx title="separator-import.tsx"
import { Separator } from "@pycolors/ui";
```

### Basic usage

Use a horizontal Separator to divide related content blocks.

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <div className="w-full max-w-xl rounded-2xl border border-border/60 bg-card p-5">
        <div>
          <div className="text-sm font-medium text-foreground">
            Account
          </div>

          <div className="mt-1 text-sm text-muted-foreground">
            Manage profile settings and preferences.
          </div>
        </div>

        <Separator className="my-4" />

        <div>
          <div className="text-sm font-medium text-foreground">
            Billing
          </div>

          <div className="mt-1 text-sm text-muted-foreground">
            Review invoices, plan status, and payment settings.
          </div>
        </div>
      </div>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="basic-separator.tsx"
    import { Separator } from "@pycolors/ui";

    export function BasicSeparator() {
      return (
        <div className="rounded-2xl border border-border/60 bg-card p-5">
          <div>
            <div className="text-sm font-medium text-foreground">
              Account
            </div>
            <div className="mt-1 text-sm text-muted-foreground">
              Manage profile settings and preferences.
            </div>
          </div>

          <Separator className="my-4" />

          <div>
            <div className="text-sm font-medium text-foreground">
              Billing
            </div>
            <div className="mt-1 text-sm text-muted-foreground">
              Review invoices, plan status, and payment settings.
            </div>
          </div>
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

<Callout type="info" title="Default behavior">
  Separator is decorative by default. It renders without separator semantics unless you explicitly set `decorative={false}`.
</Callout>

## When to use Separator

Use Separator when spacing alone is not enough to communicate grouping.

<DocsFeatureGrid
  columns={3}
  tone="platform"
  items={[
  {
    title: 'Sections',
    description:
      'Separate related content groups inside cards, panels, and forms.',
    icon: Rows3,
  },
  {
    title: 'Toolbars',
    description:
      'Divide compact action groups without introducing heavy borders.',
    icon: Columns3,
  },
  {
    title: 'Hierarchy',
    description:
      'Make dense information easier to scan while keeping the layout calm.',
    icon: ListTree,
  },
]}
/>

### Orientation

Separator supports horizontal and vertical orientation.

### Horizontal

Horizontal is the default orientation.

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <div className="w-full max-w-xl rounded-2xl border border-border/60 bg-card p-5">
        <div className="text-sm font-medium text-foreground">
          Starter Pro
        </div>

        <div className="mt-1 text-sm leading-6 text-muted-foreground">
          Production-ready SaaS starter with authentication, billing, and protected app foundations.
        </div>

        <Separator className="my-4" />

        <div className="flex flex-wrap gap-2">
          <Badge variant="outline">
            Auth
          </Badge>

          <Badge variant="outline">
            Stripe
          </Badge>

          <Badge variant="outline">
            Prisma
          </Badge>
        </div>
      </div>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="horizontal-separator.tsx"
    import { Badge, Separator } from "@pycolors/ui";

    export function HorizontalSeparator() {
      return (
        <div className="rounded-2xl border border-border/60 bg-card p-5">
          <div className="text-sm font-medium text-foreground">
            Starter Pro
          </div>
          <div className="mt-1 text-sm leading-6 text-muted-foreground">
            Production-ready SaaS starter with authentication, billing, and protected app foundations.
          </div>

          <Separator className="my-4" />

          <div className="flex flex-wrap gap-2">
            <Badge variant="outline">Auth</Badge>
            <Badge variant="outline">Stripe</Badge>
            <Badge variant="outline">Prisma</Badge>
          </div>
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

### Vertical

Use a vertical Separator inside a flex row. Give the parent a height or use `self-stretch`.

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <div className="flex h-12 items-center rounded-2xl border border-border/60 bg-card px-4">
        <div className="text-sm font-medium text-foreground">
          Free
        </div>

        <Separator orientation="vertical" className="mx-4" />

        <div className="text-sm font-medium text-foreground">
          Pro
        </div>

        <Separator orientation="vertical" className="mx-4" />

        <div className="text-sm font-medium text-foreground">
          Enterprise
        </div>
      </div>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="vertical-separator.tsx"
    import { Separator } from "@pycolors/ui";

    export function VerticalSeparator() {
      return (
        <div className="flex h-12 items-center rounded-2xl border border-border/60 bg-card px-4">
          <div className="text-sm font-medium text-foreground">
            Free
          </div>

          <Separator orientation="vertical" className="mx-4" />

          <div className="text-sm font-medium text-foreground">
            Pro
          </div>

          <Separator orientation="vertical" className="mx-4" />

          <div className="text-sm font-medium text-foreground">
            Enterprise
          </div>
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

<Callout title="Vertical rule">
  Vertical separators need layout height. Use them inside rows, toolbars, navs, or compact metadata groups.
</Callout>

## Decorative vs semantic

By default, Separator is decorative and uses `role="none"`.

Set `decorative={false}` when the separator communicates a meaningful boundary for assistive technologies.

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <div className="w-full max-w-xl rounded-2xl border border-border/60 bg-card p-5">
        <section>
          <h3 className="text-sm font-medium text-foreground">
            Personal details
          </h3>

          <div className="mt-1 text-sm leading-6 text-muted-foreground">
            Name, email, and account profile.
          </div>
        </section>

        <Separator decorative={false} className="my-4" />

        <section>
          <h3 className="text-sm font-medium text-foreground">
            Workspace details
          </h3>

          <div className="mt-1 text-sm leading-6 text-muted-foreground">
            Team, role, and organization settings.
          </div>
        </section>
      </div>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="semantic-separator.tsx"
    import { Separator } from "@pycolors/ui";

    export function SemanticSeparator() {
      return (
        <div className="rounded-2xl border border-border/60 bg-card p-5">
          <section>
            <h3 className="text-sm font-medium text-foreground">
              Personal details
            </h3>
            <p className="mt-1 text-sm leading-6 text-muted-foreground">
              Name, email, and account profile.
            </p>
          </section>

          <Separator decorative={false} className="my-4" />

          <section>
            <h3 className="text-sm font-medium text-foreground">
              Workspace details
            </h3>
            <p className="mt-1 text-sm leading-6 text-muted-foreground">
              Team, role, and organization settings.
            </p>
          </section>
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

<Callout type="info" title="Semantic rule">
  Most separators should stay decorative. Use semantic separators only when the boundary itself helps describe the structure.
</Callout>

### Settings card

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <div className="w-full max-w-xl rounded-2xl border border-border/60 bg-card">
        <div className="p-5">
          <div className="text-sm font-medium text-foreground">
            Notifications
          </div>

          <div className="mt-1 text-sm text-muted-foreground">
            Choose how PyColors should contact you.
          </div>
        </div>

        <Separator />

        <div className="grid gap-4 p-5">
          <div className="flex items-center justify-between gap-4">
            <div>
              <div className="text-sm font-medium text-foreground">
                Product updates
              </div>

              <div className="text-sm text-muted-foreground">
                Receive release notes and roadmap updates.
              </div>
            </div>

            <Badge variant="outline">
              Enabled
            </Badge>
          </div>

          <Separator />

          <div className="flex items-center justify-between gap-4">
            <div>
              <div className="text-sm font-medium text-foreground">
                Security alerts
              </div>

              <div className="text-sm text-muted-foreground">
                Important account and billing notifications.
              </div>
            </div>

            <Badge>
              Required
            </Badge>
          </div>
        </div>
      </div>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="settings-card-separators.tsx"
    import { Badge, Separator } from "@pycolors/ui";

    export function SettingsCardSeparators() {
      return (
        <div className="rounded-2xl border border-border/60 bg-card">
          <div className="p-5">
            <div className="text-sm font-medium text-foreground">
              Notifications
            </div>
            <div className="mt-1 text-sm text-muted-foreground">
              Choose how PyColors should contact you.
            </div>
          </div>

          <Separator />

          <div className="grid gap-4 p-5">
            <div className="flex items-center justify-between gap-4">
              <div>
                <div className="text-sm font-medium text-foreground">
                  Product updates
                </div>
                <div className="text-sm text-muted-foreground">
                  Receive release notes and roadmap updates.
                </div>
              </div>
              <Badge variant="outline">Enabled</Badge>
            </div>

            <Separator />

            <div className="flex items-center justify-between gap-4">
              <div>
                <div className="text-sm font-medium text-foreground">
                  Security alerts
                </div>
                <div className="text-sm text-muted-foreground">
                  Important account and billing notifications.
                </div>
              </div>
              <Badge>Required</Badge>
            </div>
          </div>
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

### Compact metadata

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <div className="flex h-10 items-center rounded-2xl border border-border/60 bg-card px-4 text-sm text-muted-foreground">
        <span>
          v1.10.0
        </span>

        <Separator orientation="vertical" className="mx-3" />

        <span>
          Released Apr 24, 2026
        </span>

        <Separator orientation="vertical" className="mx-3 hidden sm:block" />

        <span className="hidden sm:inline">
          Marketing
        </span>
      </div>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="metadata-separator.tsx"
    import { Separator } from "@pycolors/ui";

    export function MetadataSeparator() {
      return (
        <div className="flex h-10 items-center rounded-2xl border border-border/60 bg-card px-4 text-sm text-muted-foreground">
          <span>v1.10.0</span>
          <Separator orientation="vertical" className="mx-3" />
          <span>Released Apr 24, 2026</span>
          <Separator orientation="vertical" className="mx-3 hidden sm:block" />
          <span className="hidden sm:inline">Marketing</span>
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

### Usage patterns

<Steps>
  <Step>
    #### Start with spacing

    Use spacing first. Add Separator only when visual grouping is still unclear.
  </Step>

  <Step>
    #### Keep dividers subtle

    Use semantic border tokens. Avoid strong colors unless the divider is part of a very specific branded surface.
  </Step>

  <Step>
    #### Pick the right orientation

    Use horizontal dividers for stacked content and vertical dividers for compact rows.
  </Step>

  <Step>
    #### Avoid over-fragmenting the page

    Too many separators make the UI feel heavy and harder to scan.
  </Step>
</Steps>

## Separator vs Border vs Card

| Situation                             | Use                     |
| ------------------------------------- | ----------------------- |
| Split content inside the same surface | Separator               |
| Define the edge of a surface          | Border                  |
| Group content into a distinct object  | Card                    |
| Divide toolbar action groups          | Separator               |
| Separate unrelated page regions       | Section spacing or Card |
| Emphasize a critical state            | Alert or semantic color |

<Callout title="Decision rule">
  Use Separator inside a surface. Use Card when the content deserves its own surface.
</Callout>

## API

| Prop          | Type                                   | Default        | Description                           |
| ------------- | -------------------------------------- | -------------- | ------------------------------------- |
| `orientation` | `"horizontal" \| "vertical"`           | `"horizontal"` | Divider direction                     |
| `decorative`  | `boolean`                              | `true`         | Removes separator semantics when true |
| `className`   | `string`                               | —              | Additional Tailwind classes           |
| `...props`    | `React.HTMLAttributes<HTMLDivElement>` | —              | Standard div attributes               |

### TypeScript types

```ts title="separator-types.ts"
export interface SeparatorProps
  extends React.HTMLAttributes<HTMLDivElement> {
  orientation?: "horizontal" | "vertical";
  decorative?: boolean;
}
```

### Accessibility

* Decorative separators use `role="none"`.
* Semantic separators use `role="separator"`.
* Semantic separators include `aria-orientation`.
* Most visual dividers should be decorative.
* Do not use Separator as a replacement for headings.
* Do not rely on a divider alone to explain hierarchy.

<Callout title="Accessibility rule">
  If the separator does not add meaning for screen reader users, keep it decorative.
</Callout>

## Prefer / avoid

<PreferAvoid
  prefer={[
  'subtle dividers inside cards and panels',
  'horizontal separators for stacked sections',
  'vertical separators for compact rows',
  'decorative separators by default',
  'spacing before adding extra lines',
]}
  avoid={[
  'using separators as decoration',
  'too many dividers in dense layouts',
  'strong colors for neutral separation',
  'semantic separators without structural value',
  'replacing headings with divider lines',
]}
/>

## Common questions

<Accordions type="single">
  <Accordion title="Should Separator be semantic by default?">
    No. Most separators are visual only. PyColors keeps them decorative by default to avoid unnecessary screen reader noise.
  </Accordion>

  <Accordion title="Why does vertical Separator sometimes not appear?">
    Vertical separators need height from the parent layout. Use them inside a row with a fixed height, `items-stretch`, or an explicit height class.
  </Accordion>

  <Accordion title="Should I use Separator between every list item?">
    Usually no. Use spacing, row backgrounds, or borders only when density requires stronger grouping.
  </Accordion>

  <Accordion title="Can Separator use custom colors?">
    Yes through `className`, but prefer semantic tokens like `bg-border`, `bg-border-subtle`, or theme-specific tokens when available.
  </Accordion>
</Accordions>

## Related

<DocsLinks
  variant="list"
  tone="platform"
  items={[
  {
    title: 'Card',
    href: '/docs/ui/card',
    description:
      'Use Card when content needs its own surface and boundary.',
    icon: PanelsTopLeft,
  },
  {
    title: 'Colors',
    href: '/docs/design-system/colors',
    description:
      'Semantic tokens for borders, surfaces, and layout dividers.',
    icon: Palette,
  },
  {
    title: 'Badge',
    href: '/docs/ui/badge',
    description:
      'Pair badges with separators in metadata and compact status rows.',
    icon: Tags,
  },
  {
    title: 'Layout pattern',
    href: '/docs/patterns/layout',
    description:
      'Build clearer page structure with spacing, surfaces, and dividers.',
    icon: LayoutTemplate,
  },
]}
/>