1. framework components
  2. segmented control

Segmented Control

Capture input for a limited set of options.

Browse

You selected music

Icons

To adhere to accessibility best practices, include title and aria-label when using icon labels.

Orientation

Using the orientation prop to control the layout.

Anatomy

Here’s an overview of how the SegmentedControl component is structured in code:

svelte
<script lang="ts">
	import { SegmentedControl } from '@skeletonlabs/skeleton-svelte';
</script>

<SegmentedControl>
	<SegmentedControl.Label />
	<SegmentedControl.Control>
		<SegmentedControl.Indicator />
		<SegmentedControl.Item>
			<SegmentedControl.ItemText />
			<SegmentedControl.ItemHiddenInput />
		</SegmentedControl.Item>
	</SegmentedControl.Control>
</SegmentedControl>

API Reference

Root

Prop Default Type
ids Partial<{ root: string; label: string; indicator: string; item: (value: string) => string; itemLabel: (value: string) => string; itemControl: (value: string) => string; itemHiddenInput: (value: string) => string; }> | undefined

The ids of the elements in the radio. Useful for composition.

value string | null | undefined

The controlled value of the radio group

defaultValue string | null | undefined

The initial value of the checked radio when rendered. Use when you don't need to control the value of the radio group.

name string | undefined

The name of the input fields in the radio (Useful for form submission).

form string | undefined

The associate form of the underlying input.

disabled boolean | undefined

If `true`, the radio group will be disabled

invalid boolean | undefined

If `true`, the radio group is marked as invalid.

required boolean | undefined

If `true`, the radio group is marked as required.

readOnly boolean | undefined

Whether the radio group is read-only

onValueChange ((details: ValueChangeDetails) => void) | undefined

Function called once a radio is checked

orientation "horizontal" | "vertical" | undefined

Orientation of the radio group

dir "ltr" "ltr" | "rtl" | undefined

The document's text/writing direction.

getRootNode (() => ShadowRoot | Node | Document) | undefined

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

element Snippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Provider

Prop Default Type
value () => RadioGroupApi<PropTypes>

element Snippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Context

Prop Default Type
children Snippet<[() => RadioGroupApi<PropTypes>]>

Label

Prop Default Type
element Snippet<[HTMLAttributes<"span">]> | undefined

Render the element yourself

Control

Prop Default Type
element Snippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Indicator

Prop Default Type
element Snippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Item

Prop Default Type
value string

disabled boolean | undefined

invalid boolean | undefined

element Snippet<[HTMLAttributes<"label">]> | undefined

Render the element yourself

ItemText

Prop Default Type
element Snippet<[HTMLAttributes<"span">]> | undefined

Render the element yourself

ItemHiddenInput

Prop Default Type
element Snippet<[HTMLAttributes<"input">]> | undefined

Render the element yourself

View page on GitHub