Segmented
Compact single-choice control for switching related views or modes.
Segmented composes a container component with projected native buttons marked by kuiSegment.
import { KuiSegment, KuiSegmented } from '@kikita-labs/ui';Bind the selected segment with a signal and keep each projected button native.
Selected view: list
<div class="basic-segmented-example">
<kui-segmented [(value)]="view" aria-label="Project view">
<button kuiSegment value="list">List</button>
<button kuiSegment value="board">Board</button>
<button kuiSegment value="timeline">Timeline</button>
</kui-segmented>
<p>Selected view: {{ view() }}</p>
</div>Set defaults.segmented once for the application or for a subtree. Each option resolves as local input > defaults.segmented.<option> > built-in default.
import { provideKikitaUi } from '@kikita-labs/ui';
export const appConfig: ApplicationConfig = {
providers: [
provideKikitaUi({
defaults: {
segmented: {
/* options below */
},
},
}),
],
};| Name | Type | Default | Description |
|---|---|---|---|
| size | 'xs' | 'sm' | 'md' | 'lg' | — | Component size. Takes precedence over the global defaults.size. |
Set any of these on the component or an ancestor to restyle one part. Each token is optional: when it is not set, the part uses the role or scale token in the default column.
| Name | Type | Default | Description |
|---|---|---|---|
| --kui-seg-focus-ring-color | CSS custom property | --kui-color-focus | Focus ring color |
Inputs verified against @kikita-labs/ui v2.0.0 public typings.
| Name | Type | Default | Description |
|---|---|---|---|
| [(value)] | string | '' | Selected segment value. Implements FormValueControl for [formField] integration, or bind directly for standalone use. |
| [(selected)] | string | '' | Deprecated alias for value, kept in sync with it. Use value instead; planned for removal in the next major version. |
| size | 'xs' | 'sm' | 'md' | 'lg' | undefined | undefined | Control height and spacing for the whole segmented group. Falls back to defaults.segmented.size, then the global defaults.size, then md. |
| disabled | boolean | false | Disables every segment. Set by [formField] or directly. |
| invalid | boolean | false | Marks the control as having validation errors. Set by [formField]. |
| errors | readonly WithOptionalFieldTree<ValidationError>[] | [] | Current validation errors. Set by [formField]. |
| touched | boolean | false | Whether the control has been touched. Set by [formField]. |
| (touch) | void | - | Emitted whenever an enabled segment is selected, including one that was already selected; marks the control as touched in the form system. Focus and blur alone do not emit it. |
| button[kuiSegment].value | string | '' | Value emitted when the segment is selected. |
| button[kuiSegment].disabled | boolean | false | Disables one segment and removes it from keyboard selection. |
| focus(options?) | (options?: FocusOptions) => void | - | Focuses the selected segment, or the first enabled one when nothing is selected, so Signal Forms focusBoundControl() reaches the control. Does nothing while every segment is disabled. |
| required | - | - | Not available: a segmented control always shows one active segment, so it exposes no required state. |
| KuiSegmentedOptions | interface | - | Shape of defaults.segmented: size. |
Changes introduced in @kikita-labs/ui v1.5.0 that affect existing markup.
- Segmented now implements
FormValueControl<string>and accepts[formField]directly onkui-segmentedfor Signal Forms integration. - The
selected/selectedChangemodel is deprecated in favor ofvalue/valueChange. Existing[(selected)]bindings keep working and stay in sync withvalue, but are planned for removal in the next major version. New markup should use[(value)].
Segmented uses radiogroup semantics while preserving native button focus.
- The container renders
role="radiogroup". ArrowLeft,ArrowRight,ArrowUpandArrowDownmove focus between segments;HomeandEndfocus the first and last;EnterandSpaceselect the focused segment.- Each segment button renders
role="radio"and selection state. - Disabled segments cannot be selected.
focus()lands on the selected segment, so Signal FormsfocusBoundControl()reaches the control instead of the group host.- Use an accessible label on the segmented group when nearby text is not enough.
Consumer-visible changes of @kikita-labs/ui 2.0 for Segmented.
- The classes are
KuiSegmentedandKuiSegment; theComponentandDirectivesuffixes are gone. - The default size moved to
provideKuiDefaults({ segmented: { size } }); the input is nowundefineduntil set. kui-segmentedgainsfocus(options?), so Signal FormsfocusBoundControl()reaches the selected segment.ArrowUpandArrowDownnow also move focus between segments.- The focus ring has
--kui-seg-focus-ring-color, and disabled segments use the shared--kui-opacity-disabled.