SegmentedControl
A compact group of segments for choosing one view or option.
Usage
<script>
import { Label, SegmentedControl, SegmentedControlItem } from 'fluentui-svelte';
let selectedValue = $state('day');
</script>
<Label label="View">
<SegmentedControl name="view" bind:selectedValue>
<SegmentedControlItem value="day">Day</SegmentedControlItem>
<SegmentedControlItem value="week">Week</SegmentedControlItem>
<SegmentedControlItem value="month">Month</SegmentedControlItem>
</SegmentedControl>
</Label> Arrow keys move focus; Space or Enter selects. Set selectOnFocus to select while navigating. Tab enters the selected radio. Use Label, aria-label or aria-labelledby to name the group.
Text, icons and mixed content
Use short text labels, icons with accessible names, or icons alongside text. The icon prop accepts a Fluent icon component or a Svelte snippet. Every option needs a unique value within its group.
Equal widths or fit to content
Segments have equal widths by default. Set equalWidth to false to fit each segment to its content.
Sizes
Choose size: small for compact rows, medium for standard controls or large when more space is available. The size is shared by every segment in the group.
Selection indicator
Set hideIndicator to hide the selection indicator.
Selection on focus
Arrow keys move focus without changing the selection. Enable selectOnFocus to select the focused segment.
Disabled options and groups
Disable one option to keep it visible while unavailable, or disable the whole group. Disabled radios are skipped by keyboard navigation and excluded from FormData and validation.
Using Label
Wrap SegmentedControl in Label to name the group automatically. Each option retains its own text or aria-label. An explicit aria-label or aria-labelledby on the group takes precedence. Label marks a field as required visually; set required on SegmentedControl to enable validation.
Submission, validation and reset
Set name to the field name your form expects. Only the checked enabled radio is submitted. required prevents submission until an option is selected. Reset restores the selection captured when the group was created, including an initially empty selection, and updates bind:selectedValue.
External forms
Set form to the id of a form elsewhere on the page. Every radio belongs to that form and participates in its submission, validation and reset behavior.
Binding and change events
Bind selectedValue to read or update the selection. onSelectionChange receives the native change event and the new string value. Selecting the same option, updating the binding programmatically or resetting the form does not call it.
SegmentedControl
| Name | Type | Default | Description |
|---|---|---|---|
ref bindable | HTMLDivElement | null | The DOM reference of the control. | |
selectedValue bindable | string | The value of the selected item. An empty value leaves all items unselected. | |
name | string | The field name shared by every radio. Defaults to a unique generated name. | |
form | string | The id of the form that owns the radios, when outside that form. | |
required | boolean | false | Requires a selection before the form can be submitted. |
validationMessage | string | Custom native validation message when a required selection is missing. | |
hideIndicator | boolean | false | Hides the accent indicator beneath the selected segment. |
selectOnFocus | boolean | false | Selects the focused segment during arrow-key navigation. |
onSelectionChange | (event: Event, value: string) => void | Fired when user interaction changes the selection. | |
size | 'small' | 'medium' | 'large' | 'medium' | The size of every segment. |
equalWidth | boolean | true | Gives every segment the same width. Disable to fit each segment to its content. |
disabled | boolean | false | Disables every segment. |
disableTabspot | boolean | false | Disables tabspot keyboard navigation. |
| HTML Attributes |
SegmentedControlItem
| Name | Type | Default | Description |
|---|---|---|---|
ref bindable | HTMLInputElement | null | The DOM reference of the native radio input. | |
value | string | A unique value identifying this segment within its control. | |
icon | Snippet | Component | An optional icon. Give icon-only items an accessible name with aria-label. | |
disabled | boolean | false | Disables this segment. |
children | Snippet | The content of the segment's label. | |
| HTML Attributes |

