# Rule (rule)

> A labelled divider with ink or vermilion emphasis and two line weights.

- Entry: component
- Category: UI
- Preview capabilities: none (still preview)
- Runtime: React
- Needs Remotion: no
- QA page: https://jbm-ui.bns.studio/c/rule
- JSON: https://jbm-ui.bns.studio/catalog/rule.json
- Registry item: https://jbm-ui.bns.studio/r/rule.json (source code in files[].content)

## Install

```sh
npx shadcn@latest add @jbm/rule
```

Also installs @jbm/tokens (registry dependencies install automatically).

## Required setup

1. Add the `@jbm` registry to components.json (keep any entries already there):

   ```json
   {
     "registries": {
       "@jbm": "https://jbm-ui.bns.studio/r/{name}.json"
     }
   }
   ```

2. Map `@/*` to `./src/*` in tsconfig.json `compilerOptions.paths`, so `@/jbm/…` imports resolve to src/jbm/.

## Files

Each file's source code is in the registry item JSON (https://jbm-ui.bns.studio/r/rule.json, files[].content).

| Source path | Installs to | Import |
| --- | --- | --- |
| `registry/jbm/ui/rule.tsx` | `src/jbm/ui/rule.tsx` | `@/jbm/ui/rule` |

## API

### `Rule` (component)

A full-width separator (role="separator") with an optional uppercase mono label before a flexible line. The line is 1px hairline by default or 3px when strong; its color is the line token, ink when strong, or vermilion when accent. Other div attributes pass through.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | none | Optional editorial label (Geist Mono, 13px, uppercase) shown before the line; also becomes the separator's aria-label. Dim, or vermilion with `accent`. |
| `strong` | `boolean` | `false` | Uses a 3px line instead of 1px, and ink instead of the hairline color when not accented. |
| `accent` | `boolean` | `false` | Colors the line and label vermilion. Keep to one accent per composition. |

Also accepts React.HTMLAttributes<HTMLDivElement>.

## Stage

fluid: Width is 100% of the container. Height is the line weight (1px, or 3px strong) without a label, or one line of 13px mono label text with a label; long labels wrap anywhere and add lines. The line keeps a 24px minimum width.

## Examples

### Labelled accent rule

```tsx
import { Rule } from "@/jbm/ui/rule"

<Rule label="Una idea a la vez" accent strong />
<Rule />
<Rule label="El siguiente capítulo" strong />
```

## QA

- Compare the four looks on cream: plain hairline, strong ink, labelled, and accent strong; the label sits on the line's vertical center with a 16px gap.
- Check a long label on a narrow screen: it wraps and the line keeps at least 24px.
- Confirm the separator is announced with its label as the accessible name, and without one when unlabelled.

## Related

Installs:

- [Tokens (tokens)](https://jbm-ui.bns.studio/catalog/tokens.md)

## More

- [llms.txt](https://jbm-ui.bns.studio/llms.txt): index of every item
- [catalog.json](https://jbm-ui.bns.studio/catalog.json): every item as JSON
- [Agent contract](https://jbm-ui.bns.studio/docs/agent-contract.md): what each field means
