Skip to main content
The Segmented Button component provides a visually distinct alternative to radio buttons, displaying options as a connected group of buttons.

Basic usage

<flx-segmented-button [(ngModel)]="selectedView">
  <flx-segment value="grid" label="Grid" icon="grid"></flx-segment>
  <flx-segment value="list" label="List" icon="list"></flx-segment>
  <flx-segment value="table" label="Table" icon="table"></flx-segment>
</flx-segmented-button>

Properties

value
any
Currently selected value
disabled
boolean
default:"false"
Disables all segments
size
'small' | 'medium' | 'large'
default:"medium"
Size of the segmented button
variant
'fill' | 'outline'
default:"fill"
Visual style of the control

Segment properties

value
any
required
Value of this segment
label
string
Label text for the segment
icon
string
Icon to display in the segment
disabled
boolean
default:"false"
Disables this specific segment

Events

valueChange
EventEmitter<any>
Emitted when the selected value changes

Examples

<flx-segmented-button [(ngModel)]="viewMode">
  <flx-segment value="grid" icon="grid"></flx-segment>
  <flx-segment value="list" icon="list"></flx-segment>
  <flx-segment value="map" icon="map"></flx-segment>
</flx-segmented-button>
export class ContentView {
  viewMode = 'grid';
}

Styling

flx-segmented-button {
  --flx-segment-height: 36px;
  --flx-segment-padding: 0 16px;
  --flx-segment-border-radius: 6px;
  --flx-segment-border-color: #d1d5db;
  --flx-segment-background: #ffffff;
  --flx-segment-hover-background: #f3f4f6;
  --flx-segment-active-background: #3b82f6;
  --flx-segment-active-color: #ffffff;
  --flx-segment-text-color: #374151;
}

Accessibility

The Segmented Button implements radio group semantics:
  • Arrow keys navigate between segments
  • Space/Enter selects the focused segment
  • role="radiogroup" for the container
  • role="radio" for each segment
  • aria-checked reflects selection state

Best practices

  • Use for 2-5 mutually exclusive options
  • Prefer icons for space-constrained layouts
  • Include labels for clarity when space allows
  • Use consistent icon styles across segments
  • Consider outline variant for secondary controls
Segmented buttons work best for view modes, filters, and formatting controls where users need quick visual feedback.
  • Radio - Alternative for more options
  • Switch - For binary on/off choices
  • Button - For action triggers

Build docs developers (and LLMs) love