Forms

Segment

Individual option inside a SegmentedControl that renders either a selection button or a route-backed link with shared segmented styling.

import { Segment } from '@lostgradient/cinder';
formselection
01

Overview

Individual option inside a SegmentedControl that renders either a selection button or a route-backed link with shared segmented styling.

Usage

svelte
<script lang="ts">
  import { Segment } from '@lostgradient/cinder';
  import { SegmentedControl } from '@lostgradient/cinder';

  let view = $state('list');
</script>

<SegmentedControl id="view-toggle" label="View" selectionMode="single" bind:value={view}>
  <Segment value="list">List</Segment>
  <Segment value="grid">Grid</Segment>
</SegmentedControl>

Guidance

Use When

  • Authoring SegmentedControl children declaratively so consumers can compose icons, labels, and badges per segment.
  • Mixing disabled and enabled segments inside a single radiogroup/tablist where each segment carries its own metadata.
  • Rendering route filters as real links inside SegmentedControl variant="navigation".

Avoid When

  • Building a standalone toggle button — use Button or Toggle instead.
  • Selecting one option from a long list — use Select or Combobox instead.
02

When to use

Use when
  • Authoring SegmentedControl children declaratively so consumers can compose icons, labels, and badges per segment.
  • Mixing disabled and enabled segments inside a single radiogroup/tablist where each segment carries its own metadata.
  • Rendering route filters as real links inside `SegmentedControl variant="navigation"`.
Avoid when
  • Building a standalone toggle button — use Button or Toggle instead.
  • Selecting one option from a long list — use Select or Combobox instead.
03

Props

Props for segment
Name
Type
Default
Description
value text Value this segment represents. Must be unique within the parent control.
href discriminated-union Render this segment as a real link inside SegmentedControl variant="navigation".
download discriminated-union Download hint for the rendered link.
target undefined Browsing context for the rendered link.
rel undefined Relationship metadata for the rendered link.
current discriminated-union false Marks this linked segment as the current route/filter.
currentToken discriminated-union 'page' aria-current token emitted while current is true. Defaults to "page".
disabled boolean false Disable just this segment (independent of the control-level disabled).
controls discriminated-union ID of the panel this segment controls — only meaningful when the parent SegmentedControl uses variant="tablist".
count number A number drawn after the label in a muted, tabular figure: "Waiting on you 2". It is part of the segment's accessible name ("Waiting on you, 2"), so it never depends on colour. Unlike a Tab's count, zero is shown ("Running 0"); only undefined hides it. 'pending' draws a dash while the number is still loading ("All –") and reads as "All, loading".
leading Snippet | undefined Optional decorative content rendered before the label, inside aria-hidden.
trailing Snippet | undefined Optional decorative content rendered after the label, inside aria-hidden.
children required snippet The segment's label content.
onclick undefined Optional click handler for the rendered link. Disabled navigation segments prevent default and do not call this handler.