Segmented Control
A compact control for switching between mutually exclusive options. Use segmented controls when you need users to choose one option from a small set of related views or filters.View source →A compact control for switching between mutually exclusive options. Use segmented controls when you need users to choose one option from a small set of related views or filters, typically 2-5 choices.
This is an enhanced version of the SegmentedControl component from Radix Themes. For the original API reference, see the Radix Themes SegmentedControl documentation.
Playground
Installation
shellUsage
tsxAnatomy
Segmented Control is a compound component with the following parts:
tsxRoot Props
The Root component manages the selected value and provides context to child items.
Item Props
Each item represents one option in the segmented control.
Sizes
Set size for control density: 1 (24px), 2 (32px), 3 (40px), 4 (48px). Size affects both height and padding. Supports responsive objects for adaptive sizing across breakpoints.
Size 1
Compact for toolbars and dense interfaces where space is limited.
tsxSize 2
Standard size for most interface contexts and general use.
tsxSize 3
Large for important controls and mobile-friendly touch targets.
tsxSize 4
Extra large for hero sections and maximum visual impact.
tsxMaterial
Use the material prop to set control appearance. Choose solid for opaque backgrounds, or translucent for depth and separation over images or dynamic backgrounds.
Theme
Controls automatically inherit the theme's material setting.
tsxCustom
Override the theme's material for specific effects.
tsxOrientation
Use the orientation prop to switch between horizontal (default) and vertical layout. Vertical orientation works best with icon-only segments for compact toolbars, sidebars, and tool palettes.
Horizontal (Default)
Standard horizontal layout for most use cases.
tsxVertical Icon-Only (Recommended)
Vertical orientation is ideal for icon-only segments in sidebars and compact interfaces.
tsxVertical with Text
Text labels in vertical orientation are supported but less ideal. Use only with very short labels (1-2 words).
tsxBest Practice: For longer text labels, prefer horizontal orientation or consider using a different component like Radio Group or Tabs.
Icon-Only
Use the iconOnly prop on items to create compact, icon-based controls. Icon-only items use fixed square dimensions and remove horizontal padding for perfect centering.
tsxImportant: Always provide aria-label when using iconOnly to ensure screen reader accessibility.
States
Active
The selected item displays with a sliding background indicator and increased font weight. The indicator animates smoothly between selections with spring physics for natural motion.
tsxHover
Unselected items show subtle background color on hover, providing clear feedback that they're interactive.
Disabled
When the Root component is disabled, all items become non-interactive with reduced opacity.
tsxExamples
Controlled State
Manage selection state externally for coordinated UI updates.
tsxText Alignment
Use segmented controls for formatting options in text editors.
tsxTime Range Selector
Perfect for date range filters and time period selection.
tsxMixed Content
Combine icons with text for clearer options while maintaining compact design.
tsxResponsive
Use responsive objects with size and orientation props to adapt across different breakpoints. The component uses a mobile-first approach.
Responsive Size
tsxResponsive Orientation
Switch between vertical on mobile and horizontal on larger screens.
tsxBreakpoints
Accessibility
SegmentedControl provides comprehensive accessibility through keyboard navigation, ARIA attributes, and screen reader support.
Keyboard Navigation
- Tab - Focuses the control (or moves to next item if already focused)
- Arrow Keys - Navigates between options and updates selection
- Space / Enter - Selects the focused option
- Home - Selects first option
- End - Selects last option
ARIA Attributes
role="radiogroup"- Indicates mutually exclusive selectionaria-label- Required for icon-only items to provide accessible namesaria-checked- Indicates which option is currently selectedaria-disabled- Indicates disabled state
Screen Readers
- Announces current selection and total number of options
- Provides clear context when navigating between options
- Indicates disabled state when control is not interactive
- Icon-only items announce their aria-label text
High Contrast
- Enhanced borders in Windows High Contrast mode
- Maintains clear visual distinction between selected and unselected states
- Focus indicators remain visible in all contrast modes
Best Practices
When to Use
- View switching: Toggle between different views of the same data (list, grid, board)
- Filtering: Switch between related filter categories (all, active, completed)
- Time periods: Select date ranges (day, week, month, year)
- Format options: Text alignment, display modes, chart types
- Sidebar tools: Vertical icon-only controls for compact navigation and tool palettes
When Not to Use
- Many options: More than 5-6 options becomes unwieldy. Consider a Select or Radio Group instead
- Independent options: Use Checkboxes when multiple selections are needed
- Navigation: Use Tabs for page-level navigation with distinct content areas
- Actions: Use Buttons for triggering actions rather than changing state
- Long text labels vertically: Vertical orientation with long text is hard to read
Guidelines
- Keep option labels short and scannable (1-2 words ideal)
- Use consistent widths unless using icon-only mode
- Provide clear aria-labels for icon-only items
- Consider mobile touch targets (use size 3 or larger on mobile)
- Ensure sufficient contrast between active and inactive states
- Prefer icon-only for vertical orientation - text labels work but are less ideal
- Use vertical orientation for sidebars, tool palettes, and compact interfaces
Enhancements
Kookie UI extends Radix Themes SegmentedControl with practical improvements:
Icon-Only Mode
New iconOnly prop creates fixed square segments perfect for compact icon-based controls. Automatically removes horizontal padding for perfect icon centering and maintains square aspect ratio matching control height.
Vertical Orientation
New orientation prop supports both horizontal and vertical layouts. Vertical orientation is optimized for icon-only segments in sidebars, tool palettes, and compact navigation rails. Text labels are supported but work best with very short content.
Automatic Icon Sizing
Icons automatically scale based on control size using consistent --content-icon-size-N tokens. Ensures visual harmony with Button and IconButton components across your interface.
Enhanced Animations
Smooth spring-based indicator transitions with optimized motion curves work seamlessly in both horizontal and vertical orientations. Separator lines automatically hide adjacent to selected items for cleaner visual hierarchy.
Material System Support
Full integration with Kookie UI's material system for solid and translucent appearances. Inherits theme material setting or overrides locally for specific effects.
Changelog
Added
iconOnlyprop for fixed-width icon-only segmentsorientationprop for horizontal and vertical layouts- Automatic icon sizing based on control size
- Responsive size and orientation support with breakpoint objects
- Material system support for solid and translucent appearances
- Smooth spring-based animations for indicator transitions in both orientations
Changed
- Uses
--content-icon-size-Ntokens for consistent icon sizing across components - Icon-only items remove padding for perfect centering in both orientations
- Separator lines automatically hide adjacent to selected items
- Indicator animations work seamlessly in vertical orientation with translateY transforms