# Separator (/docs/separator)





## API Reference [#api-reference]

<BaseUIReference href="https://base-ui.com/react/components/separator" />

## Basic [#basic]

<Preview cssProperties="separatorPlaygroundCssProperties">
  <SeparatorExample />

  <Preview.Code>
    {`
          import { Separator } from "moduix";

          export function SeparatorDemo() {
            return (
              <section aria-label="Account setup">
                <span>Account settings</span>
                <Separator />
                <span>Billing details</span>
              </section>
            );
          }
        `}
  </Preview.Code>

  <Preview.CSSProperties>
    {(context) => <SeparatorCssPropertiesPanel {...context} />}
  </Preview.CSSProperties>

  <Preview.CSSPlayground>
    {(context) => <SeparatorCssPlaygroundPanel {...context} />}
  </Preview.CSSPlayground>
</Preview>

## Anatomy [#anatomy]

`Separator` is a single visible slot. It renders an accessible divider and receives
`data-orientation` so CSS can size horizontal and vertical separators differently.

```text
Separator
└─ root[data-orientation]
```

```tsx
<Separator orientation="horizontal" />
```

| Part        | Role                                                                                                   |
| ----------- | ------------------------------------------------------------------------------------------------------ |
| `Separator` | Root divider element. Controls `orientation`, accessibility attributes, styling, and element override. |

`Separator` does not use portal-like service layers such as `portal`, `positioner`,
`backdrop`, or `viewport`. Style the root directly with `className` or the
`--separator-*` CSS properties.

## Composition [#composition]

Use `Separator` wherever related content needs a non-interactive visual divider.
Horizontal separators fill their container by default. Vertical separators are intended
for inline groups and default to `1em` height so they align with surrounding text.

Pass `orientation="vertical"` for inline layouts. Use `className` for direct styling,
CSS variables for size and color adjustments, and `render` when you need to compose the
root with another element.

## Examples [#examples]

### Vertical [#vertical]

Use `orientation="vertical"` when the separator divides inline groups, such as navigation actions.

<Preview>
  <VerticalSeparatorExample />

  <Preview.Code>
    {`
          import { Separator } from "moduix";

          export function VerticalSeparatorDemo() {
            return (
              <nav aria-label="Main navigation">
                <a href="#">Home</a>
                <a href="#">Pricing</a>
                <Separator orientation="vertical" />
                <a href="#">Sign in</a>
              </nav>
            );
          }
        `}
  </Preview.Code>
</Preview>

### Custom Styles [#custom-styles]

Pass `className` to style the root element directly or override the `--separator-*` custom properties.

<Preview>
  <CustomSeparatorExample />

  <Preview.Code>
    {`
          import { Separator } from "moduix";
          import styles from "./separator-demo.module.css";

          export function CustomSeparatorDemo() {
            return (
              <section className={styles.section} aria-label="Profile progress">
                <span>Completed profile</span>
                <Separator className={styles.customSeparator} />
                <span>Next step: billing details</span>
              </section>
            );
          }
        `}
  </Preview.Code>

  <Preview.CSS>
    {`
          .section {
            display: grid;
            gap: var(--spacing-2);
          }

          .customSeparator {
            --separator-color: var(--color-primary);
            --separator-thickness: 2px;
            --separator-length-horizontal: 8rem;
          }
        `}
  </Preview.CSS>
</Preview>

### Custom Element [#custom-element]

Use `render` to compose the separator with another element while keeping the component
state and accessibility attributes.

<Preview>
  <SeparatorExample render="<span />" />

  <Preview.Code>
    {`
          import { Separator } from "moduix";

          export function CustomElementSeparatorDemo() {
            return (
              <section aria-label="Account setup">
                <span>Account settings</span>
                <Separator render={<span />} />
                <span>Billing details</span>
              </section>
            );
          }
        `}
  </Preview.Code>
</Preview>
