> For the complete documentation index, see [llms.txt](https://voit.gitbook.io/voitdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://voit.gitbook.io/voitdocs/components/segmented-control.md).

# Segmented Control

Segmented controls are used to display multiple segments, each functioning as a button that allows users to select from a set of mutually exclusive options.

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FIfNybKAMbQehpQ7TzSk7%2FFrame%20130.png?alt=media&amp;token=b77f885f-edbb-4a51-b137-249acbdeb6fd" alt="" width="330"><figcaption></figcaption></figure>

## Overview

Segmented controls are designed to help users easily switch between different sections or categories without leaving the current page.

{% embed url="<https://www.figma.com/design/4NwKhd4dwRhRF5Zpiooi69/Components?node-id=2-236495&t=0Thv0LIO2gFzE3eo-4>" %}

## When to use

* Use segmented controls when you want users to toggle between different views or filters, such as list and grid view, without needing additional navigation.&#x20;
* Ideal when you need users to select only one option from a small set, such as sorting categories (e.g., "Recent", "Popular").&#x20;
* Use when space is limited, and you want to present options in a compact, horizontal format, like on mobile devices.&#x20;
* For interfaces where users expect immediate feedback upon selection, segmented controls ensure quick updates to reflect the chosen option.

## When not to use

* Do not use segmented controls if there are too many options, as they work best with 2-5 choices. Use a dropdown or another component instead.&#x20;
* Avoid segmented controls when users need to select more than one option at a time; use multi-select components in such cases.&#x20;
* When options require additional descriptions or actions (e.g., forms), segmented controls might not provide enough space or clarity.
* &#x20;While both tabs and segmented controls allow navigation between content, but tabs switch between different views, while segmented controls are for choosing options within the same context.

## Types

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FcNqoNf2bVw4FIp3gUobw%2FTypes.png?alt=media&amp;token=40e97868-11b7-41e9-af3b-33d3a355b93b" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="174">Type</th><th></th></tr></thead><tbody><tr><td>Accent</td><td>Used to draw attention to high-priority segments in the interface.</td></tr><tr><td>Primary</td><td>The default style, typically aligned with the main theme of the interface.</td></tr><tr><td>Secondary</td><td>A subtler option for secondary or less emphasized actions.</td></tr></tbody></table>

## Anatomy

1. **Active Button:** The currently selected or highlighted segment that indicates the user's choice.&#x20;
2. **Inactive Button:** Buttons that are not selected but available for interaction, maintaining a clear state.&#x20;
3. **Divider:** A visual separator between buttons that makes the segments distinct from one another.&#x20;
4. **Button Label:** The text that describes each segment or choice, helping users understand what each option represents.&#x20;
5. **Container:** The enclosing element that holds all segments and ensures they are aligned within the interface.

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FZLjvsbQRel9dDBi1Lw4l%2FAnatomy.png?alt=media&amp;token=33380253-9850-43f8-8495-c92c9ffd15b6" alt=""><figcaption></figcaption></figure>

## Styles

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2Fj6Sz3f6qalcRRKWcGBjK%2FStyles.png?alt=media&amp;token=3f8d3b5a-d79b-435c-ab8f-82f191347ce6" alt=""><figcaption></figcaption></figure>

## Size

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FOL50gnEPeSpYs6wjxeW6%2Fsize.png?alt=media&amp;token=f9fd0592-191c-447c-9d20-87a94e9e9143" alt=""><figcaption></figcaption></figure>

| Size    | Text Label (px) | Corner (px) | Container Height (px) |
| ------- | --------------- | ----------- | --------------------- |
| Default | 14              | 10          | 38                    |

## Accessibility

* **Keyboard Navigation:** Ensure that all segments can be navigated using the keyboard, with a visible focus indicator and proper tabbing order.&#x20;
* **Consistent Interaction:** All segments should have a uniform look and feel, and selection should provide immediate visual feedback, such as highlighting the active button.&#x20;
* **Sufficient Contrast:** Make sure there is enough contrast between the active and inactive segments, as well as between the text and the background, to accommodate users with low vision or color blindness.&#x20;
* **Mobile-Friendly:** Segmented controls should be touch-friendly, ensuring buttons are large enough to be tapped easily on small screens.

## Example

* **View Switcher:** Switching between grid and list views in a product gallery.&#x20;
* **Filter Content:** Segmented control to filter content by categories like "All", "Unread", "Archived".&#x20;
* **Sort Options:** Allow users to toggle between different sorting methods like "Price", "Newest", "Ratings".&#x20;
* **Content Format Options:** Providing users the ability to choose between different content types, such as "Articles", "Videos", "Podcasts".&#x20;
* **Settings Page:** Use segmented controls to toggle between different setting sections like "General", "Security", "Notifications".
