Anchor Design System

Option4.0

Options represent individual selectable items within a select component.

Installation

npm i @tryg/vue-ui-library

Usage

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-option value="option-1" item-id="item-1">Option 1</anchor-option>
</template>

Import only the components you need for optimal bundle size.

YourComponent.vue
<script setup>
import { AnchorOption } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-option value="option-1" item-id="item-1">Option 1</anchor-option>
</template>

Label

Pass the label prop to provide a descriptive label for the option. If omitted, it falls back to using the value prop.

Vue component
<template>
  <anchor-option value="opt-1" item-id="item-1" label="Display Label">Display Label</anchor-option>
</template>

Description

Pass the description prop to provide additional context for the option. The description is rendered below the label.

Vue component
<template>
  <anchor-option value="opt-2" item-id="item-2" label="Option with description" description="An optional extra description">Option with description</anchor-option>
</template>

Disabled

Pass the disabled prop to prevent users from selecting an option.

Vue component
<template>
  <anchor-option value="opt-3" item-id="item-3" disabled>Disabled Option</anchor-option>
</template>

With Icon

Pass the icon prop to display an icon alongside the option label.

Vue component
<template>
  <anchor-option value="opt-4" item-id="item-4" icon="heart">Option with Icon</anchor-option>
</template>

Shadow Parts

PartDescription
"option"The option element

CSS variables

The following CSS custom properties are exposed:

VariableDescription
--option-background-colorSet the background color of the <anchor-option>
--option-background-color-disabledSet the background color of the <anchor-option> when disabled
--option-background-color-hoverSet the background color of the <anchor-option> on hover
--option-background-color-pressedSet the background color of the <anchor-option> when pressed
--option-border-bottom-widthSet the border bottom width of the <anchor-option>
--option-border-colorSet the border color of the <anchor-option>
--option-border-color-disabledSet the border color of the <anchor-option> when disabled
--option-border-color-hoverSet the border color of the <anchor-option> on hover
--option-border-color-pressedSet the border color of the <anchor-option> when pressed
--option-border-radiusSet the border radius of the <anchor-option>
--option-border-widthSet the border width of the <anchor-option>
--option-border-width-focusSet the border width of the <anchor-option> on focus
--option-colorSet the color of the <anchor-option>
--option-color-hoverSet the color of the <anchor-option> on hover
--option-color-pressedSet the color of the <anchor-option> when pressed
--option-cursorSet the cursor of the <anchor-option>
--option-cursor-disabledSet the cursor of the <anchor-option> when disabled
--option-cursor-pressedSet the cursor of the <anchor-option> when pressed
--option-font-familySet the font-family of the <anchor-option>
--option-font-sizeSet the font size of the <anchor-option>
--option-font-weightSet the font weight of the <anchor-option>
--option-line-heightSet the line height of the <anchor-option>
--option-line-height-insideSet the line height inside of the <anchor-option>
--option-paddingSet the padding of the <anchor-option>
--option-widthSet the width of the <anchor-option>

Accessibility

  • Supports ariaLabel for providing accessible names to assistive technologies.
  • Disabled options are communicated to screen readers.
  • Works in conjunction with the Select component for full keyboard navigation support.

API

anchor-option

Properties

PropertyAttributeDescriptionTypeDefault
ariaLabelaria-labelaria-label for the itemstringundefined
descriptiondescriptionAn optional extra description for the option. This is rendered below the labelstringundefined
disableddisabledValue indicating whether or not this particular option should be disabled from selectingbooleanfalse
focusedfocusedA value indicating whether the option has focus or not, will be used to set a class and apply focused styling.booleanundefined
iconiconValue indicating an icon to be shown inside of the option"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
itemId (required)item-idUnique identificator for this DOM nodestringundefined
labellabelA descriptive label for the option. This is what the end user will see. If this field is omitted it will fall back to use the value.stringundefined
selectedselectedA value indicating whether the option is the selected option, will be used to set a class and apply focused styling.booleanundefined
value (required)valueValue of the option. This is a unique identifier for the option that is not visible to the end userstringundefined

Shadow Parts

PartDescription
"option"

CSS Custom Properties

NameDescription
--option-background-colorSet the background color of the
--option-background-color-disabledSet the background color of the when disabled
--option-background-color-hoverSet the background color of the on hover
--option-background-color-pressedSet the background color of the when pressed
--option-border-bottom-widthSet the border bottom width of the
--option-border-colorSet the border color of the
--option-border-color-disabledSet the border color of the when disabled
--option-border-color-hoverSet the border color of the on hover
--option-border-color-pressedSet the border color of the when pressed
--option-border-radiusSet the border radius of the
--option-border-widthSet the border width of the
--option-border-width-focusSet the border width of the on focus
--option-colorSet the color of the
--option-color-hoverSet the color of the on hover
--option-color-pressedSet the color of the when pressed
--option-cursorSet the cursor of the
--option-cursor-disabledSet the cursor of the when disabled
--option-cursor-pressedSet the cursor of the when pressed
--option-description-font-sizeSet the font size of the description
--option-font-familySet the font-family of the
--option-font-sizeSet the font size of the label
--option-font-weightSet the font weight of the
--option-line-heightSet the line height of the
--option-line-height-insideSet the line height inside of the
--option-paddingSet the padding of the
--option-widthSet the width of the

Dependencies

Used by

Depends on

Graph

graph TD;
  anchor-option --> anchor-icon
  anchor-autocomplete --> anchor-option
  anchor-select --> anchor-option
  anchor-typeahead --> anchor-option
  style anchor-option fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS

On this page