Segmented handbook
v1.3.0 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Show a small set of mutually exclusive choices side by side for quick changes to filters or parameters, with keyboard and form support.
When to use it
Use radiogroup semantics for choosing one parameter or filter. Use Tab when switching content panels or views.
Use
bind:valueand stable option values. If the value is absent or unmatched, the first available item appears selected, but the binding is not updated automatically; initialize form state explicitly.For explicit items, use
Button as="item". A nonemptynameadds a hidden form field; the application restores the initial bound value on form reset.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
Default built-in mode / explicit combination mode
Specialized Tab host: Segmented renders a real Tab and accepts compatible Tab Props at the root. There is no
parts.Tab.Default built-in mode (recommended):
itemslets Tab generate Buttons;parts.Buttonconfigures those generated items.Explicit combination mode: explicitly write
<Button as="item">, and directly configure Props item by item.
Relationship with Tab
Segmented specializes Tab: the real Tab owns the visible surface, interaction nodes, and root DOM. Segmented fixes radiogroup semantics, immediate arrow-key selection, and the hidden form input supplied by name.
Segmented inherits Tab’s composite hover rules. Items do not scale by default; they retain their color and indicator feedback. Enable scaling on a child Button or through parts.Button.scaleOnHover=true.
Host Props and ownership
Type source:
ComponentProps<typeof Tab>.Controlled fields:
value,children,role,itemRole,selectionFollowsFocus,class,parts.Tab retains its variant, size, layout, indicator, keyboard behavior, Frame Props, and DOM.
Segmented adds
radiogroup/radioARIA, immediate selection, a hidden input forname, and root-level class merging.Hidden input is the non-visual auxiliary node after the Tab root; it does not copy the Tab surface.
2.1 Props
2.2 Child item contract
As in Tab.md §2.2, each child item must be <Button as="item" value="...">.
Form access
When name is set, Segmented appends <input type="hidden" name={name} value={value}> after the Tab root, exposing the current choice through native form submission.
Dynamic effect
Completely inherit Tab. See Tab.md §4 for details.
Keyboard behavior
←/→in a row or↑/↓in a column: move focus and activate immediately (selectionFollowsFocus=true).Home/End: move to the first/last option and activate.The focus behavior is consistent with Tab (roving tabindex).
Usage examples
Segmented style overlay
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
This component source does not directly consume a registered component-specific override. Style composed children through public parts or an explicit child; do not guess variable names.
Segmented Type and Status
Required Props: no named required Props.
Two-way binding: bind:value.
Inheritance statement: Omit<TabProps, ControlledTabKeys>. The inheritance ability is subject to the public document of the base class; the fields in Omit have been excluded and cannot be used as they are according to the base class.
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
ComponentPartsOf
Source: components/src/logic/component-parts.svelte.ts
ConfigurableComponentPartProps
Source: components/src/logic/component-parts.svelte.ts
ComponentPartControlledKey
Source: components/src/logic/component-parts.svelte.ts
TabProps
Source: components/src/components/Segmented.svelte
ControlledTabKeys
Source: components/src/components/Segmented.svelte