# Separator

A line that divides sections of content or groups of items. It renders a div with role separator and aria-orientation, and draws nothing: give it a size and a colour, selected by data-horizontal or data-vertical. It is not focusable.

- Entry point: `menhir/separator`
- Size: 0.7 kB, minified and gzipped, Solid left out

> To add Separator to a project, install the packages below with the project's package manager, then copy the example that matches how the project is styled, Tailwind CSS or plain CSS, and adapt its markup and class names to the project.

## Install

```sh
pnpm add menhir solid-js @solidjs/web
```

## Anatomy

```tsx
<Separator.Root />
```

## Example

### Tailwind CSS

`SeparatorExample.tsx`:

```tsx
import { Separator } from "menhir/separator";

export default function SeparatorExample() {
  return (
    <div class="w-64">
      <p>Unstyled, accessible UI primitives for SolidJS.</p>
      <Separator.Root class="my-3 h-px bg-stone-300 dark:bg-stone-700" />
      <div class="flex gap-3">
        <span>Docs</span>
        <Separator.Root
          orientation="vertical"
          class="w-px bg-stone-300 dark:bg-stone-700"
        />
        <span>Components</span>
        <Separator.Root
          orientation="vertical"
          class="w-px bg-stone-300 dark:bg-stone-700"
        />
        <span>Source</span>
      </div>
    </div>
  );
}
```

### CSS

`SeparatorExample.tsx`:

```tsx
import { Separator } from "menhir/separator";

import "./separator.css";

export default function SeparatorExample() {
  return (
    <div class="separator-example">
      <p>Unstyled, accessible UI primitives for SolidJS.</p>
      <Separator.Root class="separator" />
      <div class="separator-row">
        <span>Docs</span>
        <Separator.Root orientation="vertical" class="separator" />
        <span>Components</span>
        <Separator.Root orientation="vertical" class="separator" />
        <span>Source</span>
      </div>
    </div>
  );
}
```

`separator.css`:

```css
/* The least CSS that makes the Separator visible: a 1px line, across the
   width when horizontal and down the height when vertical, selected by
   data-horizontal and data-vertical. Everything else is the browser's.
   Colours are Tailwind's stone palette; light-dark() picks the second one
   in dark mode (color-scheme: dark). */
.separator-example {
  width: 16rem;
  font-family: system-ui, sans-serif;
}

.separator-example p {
  margin: 0;
}

.separator-row {
  display: flex;
  gap: 0.75rem;
}

.separator {
  background: light-dark(
    oklch(86.9% 0.005 56.366) /* stone-300 */,
    oklch(37.4% 0.01 67.558) /* stone-700 */
  );
}
.separator[data-horizontal] {
  height: 1px;
  margin: 0.75rem 0;
}
.separator[data-vertical] {
  width: 1px;
}
```

## API reference

### Root

<div role="separator" aria-orientation>, with data-horizontal or data-vertical. Render an <hr> with render if you prefer one; the browser then draws its border and margins.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Whether the separator divides content stacked above and below it, or side by side. |
| `render` | `(props) => JSX.Element` | — | Renders the separator with your own element. Read once. |

## Keyboard

| Keys | Action |
| --- | --- |
| `Tab` | Moves past the separator, which is not focusable. |
