3lvia/designsystem / skills/elvia-design-system
elvia-design-system
VerifiedReference for UI components and patterns in Elvia's design system ("Elvis"). Covers component- and pattern-specific guidelines for sizing, color tokens for custom UI, types, ordering, labeling, accessibility attributes, CSS setup, and web-component registration. Use when building, reviewing, or fixing UI in an Elvia frontend, even if the request doesn't name Elvia or the CSS classes explicitly (e.g. "add a save button", "make this icon bigger", "add a tooltip").
references/segmented-control.md
View on GitHub- [Segmented Control (`<elvia-segmented-control>`)](#segmented-control-elvia-segmented-control)
- [Reference](#reference)
- [Installation](#installation)
- [Use](#use)
- [Attributes](#attributes)
- [items](#items)
- [value](#value)
- [type](#type)
- [size](#size)
- [valueOnChange](#valueonchange)
- [Guidelines](#guidelines)
- [When to use](#when-to-use)
- [When not to use](#when-not-to-use)
- [Accessibility](#accessibility)
- [Examples](#examples)
# Segmented Control (`<elvia-segmented-control>`)
## Reference
https://design.elvia.io/components/segmented-control
`<elvia-segmented-control>` is a web component.
## Installation
This web component requires the `@elvia/elvis-segmented-control` package. If it is not installed, follow the
[Installation reference](./installation.md).
## Use
```html
<elvia-segmented-control
items='[{"label":"Uke"},{"label":"Måned"},{"label":"År"}]'
value="0"
></elvia-segmented-control>
```
It emits the selected index. Listen for `valueOnChange` and show the matching view.
For updates to `value` or `items` after initialization, follow the shared
[attribute and property guidance](./web-components.md#attributes-and-properties).
## Attributes
### items
Required. Pass an array of text items or icon items.
- Text items use `label`.
- Icon items use `icon`, `iconSelected`, and `ariaLabel`. `tooltip` is optional.
- Use `icon` for the unselected state and `iconSelected` for the selected state.
- Icon values are HTML strings. See [Arrays and objects](./web-components.md#arrays-and-objects) for how to
pass the value. See [Icons](./icon.md) for `<e-icon>` registration.
### value
The zero-based index of the selected item. Defaults to `0`.
### type
Set to `text` or `icon`. Defaults to `text`.
### size
Set to `small`, `medium`, or `large`. Defaults to `medium`. The component sets `<e-icon>` to 16px for small
and medium sizes, and 24px for large.
### valueOnChange
Emits when the user selects an item. The event value is the selected item index. See
[Events](./web-components.md#events).
## Guidelines
### When to use
- Use segmented control to switch between closely related subviews.
- Use segmented control to switch between a small set of views with short labels.
- As much as possible, use text with a similar size in each segment.
- Use nouns or noun phrases for segment labels.
### When not to use
- Do not use it for more than three options or long labels. Use a [Dropdown](./dropdown.md) instead.
## Accessibility
- Text items use their `label` as the radio label.
- Every icon item MUST set `ariaLabel`.
- Users can move between items with the Left/Right or Up/Down Arrow keys.
## Examples
**Input:** Switch between three time periods and show the selected view.
**Output:**
```html
<elvia-segmented-control
id="control"
items='[{"label":"Uke"},{"label":"Måned"},{"label":"År"}]'
></elvia-segmented-control>
<div id="views">
<section>Uke innhold</section>
<section hidden>Måned innhold</section>
<section hidden>År innhold</section>
</div>
```
```js
const control = document.querySelector('#control');
const views = document.querySelectorAll('#views > section');
control.addEventListener('valueOnChange', (event) => {
views.forEach((view, index) => {
view.hidden = index !== event.detail.value;
});
});
```
Use your frameworks control flow to show and hide the corresponding views.
**Input:** Use icon options to switch between image and list views.
**Output:**
```html
<elvia-segmented-control id="control" type="icon"></elvia-segmented-control>
```
```js
const control = document.querySelector('#control');
control.items = [
{
ariaLabel: 'Bildevisning',
icon: '<e-icon name="thumbnail"></e-icon>',
iconSelected: '<e-icon name="thumbnailColor"></e-icon>',
tooltip: 'Bilder',
},
{
ariaLabel: 'Listevisning',
icon: '<e-icon name="list"></e-icon>',
iconSelected: '<e-icon name="listColor"></e-icon>',
tooltip: 'Liste',
},
];
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |