Anchor Design System

Select Item3.0

AnchorSelectItem is used inside an AnchorSelect component to define individual dropdown options with support for icons, descriptions, disabled state, and selection tracking.

Installation

npm i @tryg/vue-ui-library

Usage

AnchorSelectItem defines individual options inside an AnchorSelect dropdown.

<template>
  <anchor-select>
    <anchor-select-item value="option1">Option 1</anchor-select-item>
    <anchor-select-item value="option2">Option 2</anchor-select-item>
    <anchor-select-item value="option3">Option 3</anchor-select-item>
  </anchor-select>
</template>

Install the component library as a Vue plugin. This globally registers all Anchor components.

main.js
import { createApp } from 'vue';
import { ComponentLibrary } from '@tryg/vue-ui-library';
import App from './App.vue';

const app = createApp(App);
app.use(ComponentLibrary);
app.mount('#app');
YourComponent.vue
<template>
  <anchor-select>
    <anchor-select-item value="option1">Option 1</anchor-select-item>
    <anchor-select-item value="option2">Option 2</anchor-select-item>
    <anchor-select-item value="option3">Option 3</anchor-select-item>
  </anchor-select>
</template>

Import only the components you need for optimal bundle size.

YourComponent.vue
<script setup>
import { AnchorSelect, AnchorSelectItem } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-select>
    <anchor-select-item value="option1">Option 1</anchor-select-item>
    <anchor-select-item value="option2">Option 2</anchor-select-item>
    <anchor-select-item value="option3">Option 3</anchor-select-item>
  </anchor-select>
</template>

With Description

Pass the description prop to display additional context text below the item label.

YourComponent.vue
<template>
  <anchor-select>
    <anchor-select-item value="option1" description="Standard processing">Option 1</anchor-select-item>
    <anchor-select-item value="option2" description="Priority processing">Option 2</anchor-select-item>
  </anchor-select>
</template>

With Icon

Pass the icon prop to display an icon inside the select item.

YourComponent.vue
<template>
  <anchor-select>
    <anchor-select-item icon="user" value="user">User</anchor-select-item>
    <anchor-select-item icon="settings" value="settings">Settings</anchor-select-item>
    <anchor-select-item icon="shield" value="security">Security</anchor-select-item>
  </anchor-select>
</template>

Disabled

Pass the disabled prop to prevent users from selecting a particular item.

YourComponent.vue
<template>
  <anchor-select>
    <anchor-select-item value="option1">Option 1</anchor-select-item>
    <anchor-select-item value="option2" disabled>Option 2</anchor-select-item>
    <anchor-select-item value="option3">Option 3</anchor-select-item>
  </anchor-select>
</template>

Selected

Pass the selected prop to indicate which item is currently selected.

YourComponent.vue
<template>
  <anchor-select>
    <anchor-select-item value="option1">Option 1</anchor-select-item>
    <anchor-select-item value="option2" selected>Option 2</anchor-select-item>
    <anchor-select-item value="option3">Option 3</anchor-select-item>
  </anchor-select>
</template>

CSS variables

With CSS variables you can easily customize the appearance of select items.

NameDescription
--select-item-background-colorBackground color of the select item
--select-item-background-color-disabledBackground color when disabled
--select-item-background-color-hoverBackground color when hovered
--select-item-background-color-pressedBackground color when pressed
--select-item-text-colorText color of the select item
--select-item-text-color-disabledText color when disabled
--select-item-text-color-hoverText color when hovered
--select-item-text-color-pressedText color when pressed
--select-item-border-colorBorder color of the select item
--select-item-border-color-disabledBorder color when disabled
--select-item-border-color-hoverBorder color when hovered
--select-item-border-color-pressedBorder color when pressed
--select-item-border-radiusBorder radius of the select item
--select-item-border-widthBorder width of the select item
--select-item-paddingPadding of the select item
--select-item-widthWidth of the select item
--select-item-font-familyFont family of the select item
--select-item-font-sizeFont size of the select item
--select-item-font-weightFont weight of the select item
--select-item-cursorCursor style of the select item
--select-item-cursor-disabledCursor style when disabled

Accessibility

The AnchorSelectItem component is designed to work seamlessly within the AnchorSelect dropdown to provide an accessible selection experience:

  • Keyboard navigation: Use Arrow Up and Arrow Down to navigate between select items within the dropdown. Press Enter or Space to select the focused item.
  • ARIA attributes: Each item receives appropriate aria-selected attributes to communicate selection state to assistive technologies.
  • Focus management: Visual focus indicators are provided on keyboard navigation. The focused prop tracks the currently focused item.
  • Disabled state: Disabled items are announced as disabled to screen readers and are skipped during keyboard navigation.

API

anchor-select-item

Properties

PropertyAttributeDescriptionTypeDefault
descriptiondescriptionValue to assigned to this particular SelectItem that will be emitted with the event when its selectedstringundefined
disableddisabledValue indicating whether or not this particular SelectItem should be disabled from selectingbooleanfalse
focusedfocusedValue indicating whether or not this particular SelectItem is already selectedbooleanfalse
iconiconValue indicating an icon to be shown inside of the SelectItem"activity" | "airplay" | "alarm" | "alert-circle" | "alert-octagon" | "alert-triangle" | "align-center" | "align-justify" | "align-left" | "align-right" | "anchor" | "aperture" | "archive" | "arrow-down" | "arrow-down-circle" | "arrow-down-left" | "arrow-down-right" | "arrow-left" | "arrow-left-circle" | "arrow-right" | "arrow-right-circle" | "arrow-up" | "arrow-up-circle" | "arrow-up-left" | "arrow-up-right" | "at-sign" | "award" | "band-aid" | "bar-chart" | "bar-chart-2" | "basket" | "battery" | "battery-charging" | "bell" | "bell-off" | "bluetooth" | "bold" | "bonus-tryghedsgruppen" | "book" | "book-open" | "bookmark" | "box" | "briefcase" | "calculator" | "calendar" | "camera" | "camera-off" | "cast" | "check" | "check-circle" | "check-square" | "chevron-down" | "chevron-left" | "chevron-right" | "chevron-up" | "chevrons-down" | "chevrons-left" | "chevrons-right" | "chevrons-up" | "child" | "chrome" | "circle" | "clipboard" | "clock" | "cloud" | "cloud-drizzle" | "cloud-lightning" | "cloud-off" | "cloud-rain" | "cloud-snow" | "code" | "codepen" | "codesandbox" | "coffee" | "columns" | "command" | "company" | "compass" | "copy" | "corner-down-left" | "corner-down-right" | "corner-left-down" | "corner-left-up" | "corner-right-down" | "corner-right-up" | "corner-up-left" | "corner-up-right" | "cpu" | "credit-card" | "crop" | "crosshair" | "database" | "delete" | "disc" | "divide" | "divide-circle" | "divide-square" | "dollar-sign" | "download" | "download-cloud" | "dribbble" | "droplet" | "edit" | "edit-2" | "edit-3" | "external-link" | "eye" | "eye-off" | "facebook" | "fast-forward" | "feather" | "figma" | "file" | "file-minus" | "file-pdf" | "file-plus" | "file-text" | "film" | "filter" | "flag" | "folder" | "folder-minus" | "folder-plus" | "framer" | "frown" | "gift" | "git-branch" | "git-commit" | "git-merge" | "git-pull-request" | "github" | "gitlab" | "globe" | "grid" | "hard-drive" | "hash" | "headphones" | "heart" | "help-circle" | "hexagon" | "home" | "image" | "inbox" | "info" | "instagram" | "italic" | "key" | "layers" | "layout" | "life-buoy" | "link" | "link-2" | "linkedin" | "list" | "loader" | "lock" | "log-in" | "log-out" | "mail" | "map" | "map-pin" | "maximize" | "maximize-2" | "megaphone" | "meh" | "menu" | "message-circle" | "message-square" | "mic" | "mic-off" | "minimize" | "minimize-2" | "minus" | "minus-circle" | "minus-square" | "monitor" | "moon" | "more-horizontal" | "more-vertical" | "mouse-pointer" | "move" | "music" | "navigation" | "navigation-2" | "octagon" | "offer" | "package" | "paperclip" | "pause" | "pause-circle" | "pen-tool" | "percent" | "phone" | "phone-call" | "phone-forwarded" | "phone-incoming" | "phone-missed" | "phone-off" | "phone-outgoing" | "pie-chart" | "play" | "play-circle" | "plus" | "plus-circle" | "plus-square" | "pocket" | "power" | "printer" | "radio" | "refresh-ccw" | "refresh-cw" | "repeat" | "rewind" | "rotate-ccw" | "rotate-cw" | "rss" | "save" | "scissors" | "search" | "send" | "server" | "settings" | "share" | "share-2" | "shield" | "shield-off" | "shopping-bag" | "shopping-cart" | "shuffle" | "sidebar" | "skip-back" | "skip-forward" | "slack" | "slash" | "sliders" | "smartphone" | "smile" | "speaker" | "sprout" | "square" | "star" | "star-filled" | "stop-circle" | "storm" | "sun" | "sunrise" | "sunset" | "table" | "tablet" | "tag" | "target" | "terminal" | "thermometer" | "thumbs-down" | "thumbs-up" | "toggle-left" | "toggle-right" | "tool" | "trash" | "trash-2" | "trello" | "trending-down" | "trending-up" | "triangle" | "truck" | "trygfonden" | "tv" | "twitch" | "twitter" | "type" | "umbrella" | "underline" | "unlock" | "upload" | "upload-cloud" | "user" | "user-check" | "user-minus" | "user-plus" | "user-x" | "users" | "video" | "video-off" | "voicemail" | "volume" | "volume-1" | "volume-2" | "volume-x" | "watch" | "wifi" | "wifi-off" | "wind" | "x" | "x-circle" | "x-octagon" | "x-square" | "youtube" | "zap" | "zap-off" | "zoom-in" | "zoom-out"undefined
itemIditem-idUnique identificator for this DOM nodestringundefined
readonlyreadonlyValue indicating whether or not this particular SelectItem should be readonlybooleanfalse
selectedselectedValue indicating whether or not this particular SelectItem is already selectedbooleanfalse
valuevalueValue to assigned to this particular SelectItem that will be emitted with the event when its selectedstring | { value: string; label?: string; description: string; }undefined

Events

EventDescriptionType
nextEvent emitted when attempting to navigate to the next SelectItemCustomEvent<any>
pressedEvent emitted when a SelectItem is pressedCustomEvent<any>
previousEvent emitted when attempting to navigate to the previous SelectItemCustomEvent<any>

Methods

emitSelectedEvent(e?: any) => Promise<void>

Parameters

NameTypeDescription
eany

Returns

Type: Promise<void>

CSS Custom Properties

NameDescription
--select-item-background-colorSet the background color of the
--select-item-background-color-disabledSet the background color of the when disabled
--select-item-background-color-hoverSet the background color of the when hovered
--select-item-background-color-pressedSet the background color of the when pressed
--select-item-border-colorSet the border color of the
--select-item-border-color-disabledSet the border color of the when disabled
--select-item-border-color-dividerSet the border color of the divider
--select-item-border-color-divider-disabledSet the border color of the divider when disabled
--select-item-border-color-divider-hoverSet the border color of the divider when hovered
--select-item-border-color-divider-pressedSet the border color of the divider when pressed
--select-item-border-color-hoverSet the border color of the when hovered
--select-item-border-color-pressedSet the border color of the when pressed
--select-item-border-radiusSet the border radius of the
--select-item-border-widthSet the border width of the
--select-item-border-width-focusSet the border width of the when focused
--select-item-cursorSet the cursor of the
--select-item-cursor-disabledSet the cursor of the when disabled
--select-item-cursor-pressedSet the cursor of the when pressed
--select-item-font-familySet the font family of the
--select-item-font-sizeSet the font size of the
--select-item-font-weightSet the font weight of the
--select-item-line-heightSet the line height of the
--select-item-line-height-insideSet the line height inside of the
--select-item-paddingSet the padding of the
--select-item-text-colorSet the text color of the
--select-item-text-color-disabledSet the text color of the when disabled
--select-item-text-color-hoverSet the text color of the when hovered
--select-item-text-color-pressedSet the text color of the when pressed
--select-item-widthSet the width of the

Dependencies

Used by

Depends on

Graph

graph TD;
  anchor-select-item --> anchor-icon
  anchor-phone --> anchor-select-item
  style anchor-select-item fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS

Anchor versionStatusNotes
3.0Ready for ImplementationThis component is in sync with Figma.

On this page