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/autocomplete.md

View on GitHub
- [Autocomplete (`<elvia-autocomplete>`)](#autocomplete-elvia-autocomplete)
  - [Reference](#reference)
  - [Installation](#installation)
  - [Use](#use)
  - [Attributes](#attributes)
    - [items](#items)
    - [value](#value)
    - [hasBuiltInFilter](#hasbuiltinfilter)
    - [openOnFocus](#openonfocus)
    - [size](#size)
    - [menuPosition](#menuposition)
    - [errorOptions](#erroroptions)
    - [isRequired](#isrequired)
  - [Guidelines](#guidelines)
    - [When to use](#when-to-use)
    - [When not to use](#when-not-to-use)
  - [Accessibility](#accessibility)
  - [Examples](#examples)

# Autocomplete (`<elvia-autocomplete>`)

## Reference

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

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

## Installation

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

## Use

```html
<elvia-autocomplete
  label="Sted"
  placeholder="Skriv et sted"
  items='[{"label":"Oslo","value":"Oslo"},{"label":"Hamar","value":"Hamar"}]'
></elvia-autocomplete>
```

The input accepts free text. Users do not have to select a suggestion.

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

## Attributes

### items

Set an array of objects with `label` and `value`. The `label` is a string. The `value` accepts a string or
`null`. Use unique values for the suggestions. The menu shows the label.

```js
autocomplete.items = [
  { label: 'Oslo kommune', value: 'Oslo' },
  { label: 'Hamar kommune', value: 'Hamar' },
];
```

### value

Set a string or `null`. The default is an empty string. The `valueOnChange` event emits the input text when
the user types. The `onSelectItem` event emits the item value when the user selects a suggestion. A selection
does not emit `valueOnChange`. Handle both events when the application needs every input change.

```js
autocomplete.value = 'Oslo';
```

### hasBuiltInFilter

The default is `true`. The filter matches labels with a case-insensitive substring check. It trims the search
text and returns the first six matches in item order. Set to `false` for a custom filter. Filter and sort
`items` in the application.

```js
autocomplete.hasBuiltInFilter = false;
```

### openOnFocus

The default is `false`. Set to `true` to show suggestions when an empty input receives focus. The menu stays
hidden when its only suggestion matches the input value.

```html
<elvia-autocomplete label="Sted" openOnFocus></elvia-autocomplete>
```

### size

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

```html
<elvia-autocomplete label="Sted" size="small"></elvia-autocomplete>
```

### menuPosition

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

```html
<elvia-autocomplete label="Sted" menuPosition="top"></elvia-autocomplete>
```

### errorOptions

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

- A nonempty `text` shows a custom error message and activates the error style.
- Set `hideText` to `true` to hide the internal validation message. A custom `text` remains visible.
- Set `isErrorState` to `true` to activate the error style without a message.
- Set `hasErrorPlaceholder` to `false` to remove unused error space. Custom text and internal errors retain
  this space.

```js
autocomplete.errorOptions = { text: 'Skriv et sted' };
```

### isRequired

Set to `true` to reject an empty input. This option does not require a selection from `items`. The component
validates the input on blur.

```html
<elvia-autocomplete label="Sted" isRequired></elvia-autocomplete>
```

## Guidelines

### When to use

- Use Autocomplete when users know the options and can enter a value outside the suggestion list.
- Use a custom filter when the application supplies suggestions from an external source.

### When not to use

- Use [Dropdown](https://design.elvia.io/components/dropdown) when users must select one or more predefined
  options.
- Avoid Autocomplete when users do not know the available options.

## 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.
- Preserve Up and Down Arrow navigation and Enter or Tab selection for the highlighted suggestion.

## Examples

**Input:** Show municipality labels and read the selected place.

**Output:**

```html
<elvia-autocomplete
  id="place"
  label="Sted"
  items='[{"label":"Oslo kommune","value":"Oslo"},{"label":"Hamar kommune","value":"Hamar"}]'
></elvia-autocomplete>
<p id="selected-place" aria-live="polite"></p>
```

```js
const autocomplete = document.querySelector('#place');
const selectedPlace = document.querySelector('#selected-place');

autocomplete.addEventListener('onSelectItem', (event) => {
  selectedPlace.textContent = event.detail.value ?? '';
});
```

**Input:** Show suggestions only when the place starts with the input text.

**Output:**

```html
<elvia-autocomplete id="place-prefix" label="Sted" openOnFocus></elvia-autocomplete>
```

```js
const autocomplete = document.querySelector('#place-prefix');
const places = [
  { label: 'Oslo', value: 'Oslo' },
  { label: 'Hamar', value: 'Hamar' },
];

autocomplete.hasBuiltInFilter = false;
autocomplete.items = places;
autocomplete.addEventListener('valueOnChange', (event) => {
  const query = (event.detail.value ?? '').trim().toLowerCase();
  autocomplete.items = places.filter((item) => item.label.toLowerCase().startsWith(query));
});
```
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