1. framework components
  2. segmented control

Segmented Control

Capture input for a limited set of options.

Label

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:

tsx
import { SegmentedControl } from '@skeletonlabs/skeleton-react';

export default function Anatomy() {
	return (
		<SegmentedControl>
			<SegmentedControl.Label />
			<SegmentedControl.Control>
				<SegmentedControl.Indicator />
				<SegmentedControl.Item>
					<SegmentedControl.ItemText />
					<SegmentedControl.ItemHiddenInput />
				</SegmentedControl.Item>
			</SegmentedControl.Control>
		</SegmentedControl>
	);
}

API Reference

Root

PropDefaultType
idsPartial<{ 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.

valuestring | null | undefined

The controlled value of the radio group

defaultValuestring | 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.

namestring | undefined

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

formstring | undefined

The associate form of the underlying input.

disabledboolean | undefined

If `true`, the radio group will be disabled

readOnlyboolean | undefined

Whether the checkbox 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((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Provider

PropDefaultType
valueRadioGroupApi<PropTypes>

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Context

PropDefaultType
children(ratingGroup: RadioGroupApi<PropTypes>) => ReactNode

Label

PropDefaultType
element((attributes: HTMLAttributes<"span">) => Element) | undefined

Render the element yourself

Control

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Indicator

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Item

PropDefaultType
valuestring

disabledboolean | undefined

invalidboolean | undefined

element((attributes: HTMLAttributes<"label">) => Element) | undefined

Render the element yourself

ItemText

PropDefaultType
element((attributes: HTMLAttributes<"span">) => Element) | undefined

Render the element yourself

ItemHiddenInput

PropDefaultType
element((attributes: HTMLAttributes<"input">) => Element) | undefined

Render the element yourself

View page on GitHub