← All proposals

LabeledDivider

Net-new LabeledDivider: a horizontal rule with a pill-shaped label centered on it.

Net-new componentOpen in Storybook

proposals/LabeledDivider/LabeledDivider.mdx49 lines · View on GitHub
import { Canvas, Controls, Meta, Title } from '@storybook/addon-docs/blocks';

import * as LabeledDividerStories from './LabeledDivider.stories';

<Meta of={LabeledDividerStories} name='Usage' />

<Title />

## Purpose

A horizontal rule with a pill label centered on it, to mark a point in a stream of content. The label can be swapped for any control, such as a "Show more" button that unfolds more content under the divider, or a menu button that jumps to another point in time.

## Usage

Use it to break up an event log, runtime or edge logs, a thread or an event log: a date, a jump in time, or a state change such as an agent joining. Do not use it as a plain divider with no label; use a horizontal rule for that.

- Keep the label short and translated.
- Add a `prefixIcon` and/or `suffixIcon` to the label.
- Set `label` or `action`. With neither, the divider has no name and a warning is logged in development.
- Pass `action` to swap the label for any control, centered on the line. A "Show more" Button (small, secondary, with an angle icon) is the usual case. A `MenuButton` makes a time selector, as in the With Time Selector story. The divider only places the control: the screen owns it, its `aria-expanded` and `aria-controls`, the label that changes between "Show more" and "Show less", and the content it reveals. When `action` is set, `label` and the icons are ignored, and the divider is a group, not a separator, because it holds a control.
- Use `size` `s` (default) or `xs`.
- Use `agentic` for a state change, not for dates. With `action` the tone still colors the lines either side.
- The date picker in the With Time Selector story is story-only. It is not part of the component.

## Accessibility

- Static label: the divider is `role='separator'` with an `aria-label` from `label`. The pill and the lines are hidden from assistive technology, so the label is announced once. It is not focusable.
- `action`: the divider is `role='group'` and the lines are hidden. The control inside is the screen's: it needs its own accessible name, keyboard operation and focus ring, and `aria-expanded` when it unfolds content. Move focus deliberately if content appears.
- The `agentic` tone's gradient and shimmer are decorative. The shimmer stops under `prefers-reduced-motion`. Do not rely on the tone alone to mean "agent"; say it in the label.
- Not checked: no a11y panel or contrast run in this rewrite, in light or dark.

## Sizes

| Size          | Type          | Icon | Label padding (block / inline)           |
| ------------- | ------------- | ---- | ---------------------------------------- |
| `xs`          | `pds-copy-xs` | `xs` | `--pds-spacing-4xs` / `--pds-spacing-xs` |
| `s` (default) | `pds-copy-s`  | `s`  | `--pds-spacing-3xs` / `--pds-spacing-s`  |

Footprint: the divider is full width. The pill never shrinks, and each line is at least `--pds-spacing-m` wide, so a narrow parent clips or overflows a long label. Nothing draws outside the divider's box.

## Implementation

See the table below for the available props. The other stories show every variant. The With Action story shows the "Show more" case, with the content that unfolds under it; With Time Selector shows the `action` slot holding a `MenuButton`.

<hr />

<Canvas of={LabeledDividerStories.Default} />
<Controls of={LabeledDividerStories.Default} />