Segmented Control

One value from a short row of buttons — List or Grid, a view, a setting — an indicator sliding to the one checked. A radio group, in the look of the style's tabs.

FormsExperimental

Usage

Usage

View

list

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScLabel,  ScSegmentedControl,  ScSegmentedControlIndicator,  ScSegmentedControlItem,} from '@semantic-components/ui';
/** One value from a short row: the indicator slides to the one checked. The arrows move and check; one Tab stop. */

Anatomy

The indicator first, then an item per option: the indicator sits behind the checked one, and slides when another is checked.

import { ScSegmentedControl, ScSegmentedControlIndicator, ScSegmentedControlItem } from '@semantic-components/ui';
<div scSegmentedControl [formField]="form.view">  <div scSegmentedControlIndicator></div>  <button scSegmentedControlItem value="list">List</button>  <button scSegmentedControlItem value="grid">Grid</button></div>

The indicator

Measured from the checked item, in the control: --sc-segmented-control-indicator-left, -top, -width, -height (and -right, -bottom) — again when the items resize. It doesn't slide into its first place (data-activation-direction="none"), then slides, saying which way (left, right, up, down); not with reduced motion. While nothing is checked, it has no box.

Keyboard

KeyDoes
Tab Into the control — the checked item, or the first — and out
←→↑↓ The previous / next item, checked (skipping disabled ones; wrapping, unless loop is off). Read-only: focus only
Home / EndThe first / last item, checked
SpaceChecks the item focused

Accessibility

  • A radio group of radio buttons (aria-checked), named by its field's label or aria-label. Icon-only items need sr-only text.
  • The indicator is decorative: hidden from screen readers.

Examples

Icons

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScSegmentedControl,  ScSegmentedControlIndicator,  ScSegmentedControlItem,} from '@semantic-components/ui';import {  SiTextAlignCenterIcon,  SiTextAlignEndIcon,  SiTextAlignStartIcon,

Vertical

Vertical alignment

middle

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScLabel,  ScSegmentedControl,  ScSegmentedControlIndicator,  ScSegmentedControlItem,} from '@semantic-components/ui';
/** orientation="vertical": stacked; the arrows still move both ways. */

Disabled

Theme
Billing period
import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScLabel,  ScSegmentedControl,  ScSegmentedControlIndicator,  ScSegmentedControlItem,} from '@semantic-components/ui';
/** The whole control disabled, or one item — skipped by the arrows, not focused, not checked. */

Read-only

pro

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScSegmentedControl,  ScSegmentedControlIndicator,  ScSegmentedControlItem,} from '@semantic-components/ui';
/** readonly: focusable — the arrows move focus — not changed. */@Component({  selector: 'app-read-only-segmented-control-demo',

Form

Density
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, FormRoot, form, required } from '@angular/forms/signals';import {  ScButton,  ScField,  ScFieldErrors,  ScLabel,  ScSegmentedControl,  ScSegmentedControlIndicator,  ScSegmentedControlItem,

RTL

العرض
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScLabel,  ScSegmentedControl,  ScSegmentedControlIndicator,  ScSegmentedControlItem,} from '@semantic-components/ui';

API reference

Each part takes class, merged over its own (cn: a later class wins). The look is the style's (segmentedControl, as its tabs: the bar, a tab, the selected tab's raised look on the indicator).

PartSelectorDescription
ScSegmentedControldiv[scSegmentedControl] The value: role radiogroup. exportAs scSegmentedControl: focus().
ScSegmentedControlIndicator[scSegmentedControlIndicator] Behind the checked item, sliding to it: its box in CSS variables, data-activation-direction.
ScSegmentedControlItembutton[scSegmentedControlItem] A radio button: value, disabled. data-checked, data-unchecked.
InputTypeDefaultDescription
valueT | nullnull Two-way, or [formField]. null: none checked.
orientation'horizontal' | 'vertical''horizontal' In a row or stacked; the arrows move both ways in each.
loopbooleantrue The arrows wrap.
disabled, readonly, required, invalid, touchedbooleanfalse Bound by [formField].