Skip to content

3lvia/designsystem / skills/elvia-design-system

elvia-design-system

Verified

Reference 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").

FileKindSize
README.mdmarkdown726 B
SKILL.mdskill md10.4 KB
references/accordion.mdmarkdown5.9 KB
references/alert.mdmarkdown4.3 KB
references/app-bridge.mdmarkdown3.3 KB
references/autocomplete.mdmarkdown5.5 KB
references/badge.mdmarkdown2.3 KB
references/box.mdmarkdown2.0 KB
references/breadcrumb.mdmarkdown2.9 KB
references/button.mdmarkdown6.0 KB
references/card.mdmarkdown5.6 KB
references/carousel.mdmarkdown4.4 KB
references/checkbox.mdmarkdown4.7 KB
references/chip.mdmarkdown4.1 KB
references/color-tokens.mdmarkdown5.6 KB
references/content-loader.mdmarkdown2.0 KB
references/context-menu.mdmarkdown6.6 KB
references/data-formats.mdmarkdown2.1 KB
references/datepicker-range.mdmarkdown5.4 KB
references/datepicker.mdmarkdown6.0 KB
references/divider.mdmarkdown2.4 KB
references/drag-and-drop.mdmarkdown2.0 KB
references/dropdown.mdmarkdown6.7 KB
references/empty-state.mdmarkdown3.0 KB
references/file-upload.mdmarkdown2.6 KB
references/form-field.mdmarkdown2.7 KB
references/header.mdmarkdown5.8 KB
references/icon.mdmarkdown5.0 KB
references/illustrations.mdmarkdown1.4 KB
references/input.mdmarkdown2.5 KB
references/installation.mdmarkdown2.1 KB
references/link.mdmarkdown3.3 KB
references/list.mdmarkdown2.0 KB
references/modal.mdmarkdown6.1 KB
references/pagination.mdmarkdown4.0 KB
references/popover.mdmarkdown5.3 KB
references/progress-linear.mdmarkdown3.1 KB
references/radio-button.mdmarkdown2.6 KB
references/radio-filter.mdmarkdown2.8 KB
references/search-pattern.mdmarkdown2.7 KB
references/segmented-control.mdmarkdown3.9 KB
references/shadows.mdmarkdown1.3 KB
references/slider.mdmarkdown3.6 KB
references/stepper.mdmarkdown4.7 KB
references/table.mdmarkdown8.4 KB
references/tabs.mdmarkdown3.8 KB
references/tag.mdmarkdown5.0 KB
references/thumbnail.mdmarkdown1.9 KB
references/timepicker.mdmarkdown5.1 KB
references/toast.mdmarkdown3.4 KB
references/toggle.mdmarkdown2.1 KB
references/tooltip.mdmarkdown4.1 KB
references/typography.mdmarkdown3.3 KB
references/utility-classes.mdmarkdown3.9 KB
references/web-components.mdmarkdown2.1 KB

references/dropdown.md

View on GitHub
- [Dropdown (`<elvia-dropdown>`)](#dropdown-elvia-dropdown)
  - [Reference](#reference)
  - [Installation](#installation)
  - [Use](#use)
  - [Attributes](#attributes)
    - [items](#items)
    - [value](#value)
    - [isSearchable](#issearchable)
    - [isMulti](#ismulti)
    - [hasSelectAllOption](#hasselectalloption)
    - [size](#size)
    - [isFullWidth](#isfullwidth)
    - [menuPosition](#menuposition)
    - [errorOptions](#erroroptions)
    - [hasLoadMoreItemsButton](#hasloadmoreitemsbutton)
    - [noOptionsMessage](#nooptionsmessage)
    - [labelTransformation](#labeltransformation)
  - [Guidelines](#guidelines)
    - [When to use](#when-to-use)
    - [When not to use](#when-not-to-use)
  - [Accessibility](#accessibility)
  - [Examples](#examples)

# Dropdown (`<elvia-dropdown>`)

## Reference

https://design.elvia.io/components/dropdown

`<elvia-dropdown>` is a web component.

## Installation

This web component requires the `@elvia/elvis-dropdown` package. See the
[Installation reference](./installation.md).

## Use

```html
<elvia-dropdown
  label="Velg område"
  placeholder="Velg et område"
  items='[{"label":"Oslo","value":"oslo"},{"label":"Hamar","value":"hamar"}]'
></elvia-dropdown>
```

See [Web components](./web-components.md) for attributes, properties, and events.

## Attributes

### items

Set an array of objects with `label` and `value`. Values accept strings, numbers, or `null`. Each value MUST
be unique across all nested items.

- Set `children` to an array of items for a nested menu.
- Set `icon` to an HTML string, not an icon name. Use 24px [Icons](./icon.md).
- Set `status` to `error`, `warning`, `info`, or `informative`. Add an explanation with `tooltip`.
- Set `isDisabled` on an unavailable item.

```js
dropdown.items = [
  {
    label: 'Oslo',
    value: 'oslo',
    children: [{ label: 'Sentrum', value: 'sentrum' }],
  },
  {
    label: 'Hamar',
    value: 'hamar',
    status: 'warning',
    tooltip: 'Noen måleverdier mangler',
  },
];
```

### value

Use an item value for one selection. Use an array of item values for multiple selections. Assign numbers and
arrays as properties to preserve their types. The `valueOnChange` event returns the selected value or array,
not item objects.

```js
dropdown.value = 'oslo';
```

### isSearchable

Set to `true` to filter item labels. A search in nested items shows matching leaf items in one list.

```html
<elvia-dropdown label="Velg område" isSearchable></elvia-dropdown>
```

### isMulti

Set to `true` for multiple selections. The input shows a count when two or more items are selected. When all
selectable items are selected, the input shows `allOptionsSelectedLabel`. This label defaults to `Alle` in
Norwegian and `All` in English.

```js
dropdown.isMulti = true;
dropdown.allOptionsSelectedLabel = 'Alle områder';
```

### hasSelectAllOption

Set to `true` to add a select-all option. This option applies only when `isMulti` is `true`. Use
`selectAllOption` to change its label. The label defaults to `Alle` in Norwegian and `All` in English.

```js
dropdown.hasSelectAllOption = true;
dropdown.selectAllOption = 'Velg alle områder';
```

### size

Set to `small` or `medium`. Use `small` primarily in internal systems. Keep the size consistent with other
inputs in the form.

```html
<elvia-dropdown label="Velg område" size="small"></elvia-dropdown>
```

### isFullWidth

The default maximum width is 448px. Set `isFullWidth` to `true` to fill the parent width without this limit.

```html
<elvia-dropdown label="Velg område" isFullWidth></elvia-dropdown>
```

### menuPosition

Set to `top`, `bottom`, or `auto`. The default is `auto`.

```html
<elvia-dropdown label="Velg område" menuPosition="top"></elvia-dropdown>
```

### errorOptions

Set an object with `text`, `isErrorState`, or `hasErrorPlaceholder`. The default is
`{ isErrorState: false, hasErrorPlaceholder: true }`.

- A nonempty `text` shows a custom error message and activates the error style.
- Set `isErrorState` to `true` to activate the error style without a message.
- Set `hasErrorPlaceholder` to `false` to remove the reserved space when no custom text or internal error is
  present.
- The shared type includes `hideText`, but Dropdown does not use it.

```js
dropdown.errorOptions = { text: 'Velg et område' };
```

### hasLoadMoreItemsButton

Set to `true` to show the load-more button. The `onLoadMoreItems` event requests more items. The component
does not fetch items. Handle this event in the application. Set `isLoadingMoreItems` to `true` during the
request. Append the results to `items`. Set `isLoadingMoreItems` to `false` after the request. Set
`hasLoadMoreItemsButton` to `false` when no more items are available.

```html
<elvia-dropdown label="Velg område" hasLoadMoreItemsButton></elvia-dropdown>
```

### noOptionsMessage

This text defaults to `Ingen tilgjengelige valg` in Norwegian and `No available options` in English.

```js
dropdown.noOptionsMessage = 'Ingen områder funnet';
```

### labelTransformation

Set a function that accepts an item value and returns the input label. The function changes the input label
for one selected item, not the menu label.

```js
dropdown.labelTransformation = (value) =>
  dropdown.items.find((item) => item.value === value).label.slice(0, 3);
```

## Guidelines

### When to use

- Use Dropdown for 5 to 15 options when space is limited.
- Use searchable Dropdown with a load-more button for large lists that require multiple selections.
- Keep nested menus shallow to limit their width.

### When not to use

- For fewer than five options, consider [Radio Filter](./radio-filter.md) or
  [Radio Button](./radio-button.md).
- For more than 15 options with one selection, consider [Autocomplete](./autocomplete.md).

## Accessibility

- Set `label` to provide a visible label.
- If no visible label is present, you MUST set `ariaLabel` to give the input an accessible name.

## Examples

**Input:** Select multiple areas and read the selected values.

**Output:**

```html
<elvia-dropdown id="areas" label="Velg områder" isMulti hasSelectAllOption></elvia-dropdown>
<p id="selection" aria-live="polite"></p>
```

```js
const dropdown = document.querySelector('elvia-dropdown');
const selection = document.querySelector('#selection');

dropdown.items = [
  { label: 'Oslo', value: 'oslo' },
  { label: 'Hamar', value: 'hamar' },
];
dropdown.value = [];
dropdown.addEventListener('valueOnChange', (event) => {
  selection.textContent = event.detail.value.join(', ');
});
```

**Input:** Add an empty option that clears the selection.

**Output:**

```html
<elvia-dropdown
  label="Velg område"
  placeholder="Velg et område"
  items='[{"label":"Velg et område","value":null},{"label":"Oslo","value":"oslo"},{"label":"Hamar","value":"hamar"}]'
></elvia-dropdown>
```
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: 322kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall