# Separator

> A thin line between groups.

A separator draws a thin line between groups of content, such as the sections of a card or a menu.

## When to use

- Use it between groups that belong together but read separately, such as the profile and the stats of an artist card.
- Prefer spacing first; add a line only when spacing alone doesn't show the groups.
- Use `vertical` between items in a row, such as toolbar buttons.

_Live preview of the React and Vue versions: https://design.sosialoka.tech/components/separator/_

## Anatomy

1. Horizontal separator
2. Vertical separator

A 1px line on `border`, horizontal by default.

## Variants

| Orientation | Use it for |
| --- | --- |
| `horizontal` (default) | Between stacked groups. |
| `vertical` | Between items in a row. |

## Props

| React | Vue | Flutter | Type | Default | Use |
| --- | --- | --- | --- | --- | --- |
| `orientation` | `orientation` | `ShadSeparator.horizontal` / `.vertical` | text | `horizontal` | The direction of the line. |
| always `role="separator"` | `decorative` | not announced | boolean | `true` in Vue | Whether screen readers hear it. |

## Code

**React**
```tsx
import { Separator } from "@/components/ui/separator"

export default function SeparatorDemo() {
  return (
    <div className="w-full max-w-xs rounded-lg border border-border bg-card p-4 text-sm">
      <p className="font-medium">Rara Senandika</p>
      <p className="text-muted-foreground">Penyanyi pop, Bandung</p>
      <Separator className="my-3" />
      <p className="text-muted-foreground">3 rilis · 12.480 pendengar bulanan</p>
    </div>
  )
}
```

**Vue**
```vue
<script setup lang="ts">
import { Separator } from "@/components/ui/separator"
</script>

<template>
  <div class="w-full max-w-xs rounded-lg border border-border bg-card p-4 text-sm">
    <p class="font-medium">Rara Senandika</p>
    <p class="text-muted-foreground">Penyanyi pop, Bandung</p>
    <Separator :decorative="false" class="my-3" />
    <p class="text-muted-foreground">3 rilis · 12.480 pendengar bulanan</p>
  </div>
</template>
```

**Flutter**
```dart
import 'package:flutter/widgets.dart';
import 'package:shadcn_ui/shadcn_ui.dart';

class SeparatorDemo extends StatelessWidget {
  const SeparatorDemo({super.key});

  @override
  Widget build(BuildContext context) {
    final theme = ShadTheme.of(context);
    return SizedBox(
      width: 320,
      child: ShadCard(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('Rara Senandika', style: theme.textTheme.small),
            Text('Penyanyi pop, Bandung', style: theme.textTheme.muted),
            const ShadSeparator.horizontal(margin: EdgeInsets.symmetric(vertical: 12)),
            Text('3 rilis · 12.480 pendengar bulanan', style: theme.textTheme.muted),
          ],
        ),
      ),
    );
  }
}
```

## Install

**React**
```bash
npx shadcn@latest add https://design.sosialoka.tech/r/react/separator.json
```

**Vue**
```bash
npx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/separator.json
```

## Accessibility

- A separator between real sections has `role="separator"`; a line that is only decoration is hidden from screen readers (`decorative` in Vue).
- It never takes the focus.
