npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cas-smartdesign/token-selector

v3.0.17

Published

A token-selector based on LitElement

Readme

@cas-smartdesign/token-selector

A token-selector element with SmartDesign 3.0 look & feel.

This element must be used together with the design tokens of SmartDesign. For an independent application, make sure to include the @cas-smartdesign/design-tokens package. For a web app / web widget, refer to the official documentation about design token usage.

Attributes - Token-Selector

  • selection-mode : string (default = "multi")
    • multi: it is possible to select, deselect existing tokens or create new ones with the help of a sd-input element.
    • remove-only: there is no sd-input element shown, tokens may only be removed.
    • In addition the property usage of items and selectedIndexes differs. Further information below.
  • placeholder : string (default = null)
    • Defines the default text content of the selector if there is no selected token present. Just like a placeholder for an HTML input element.
  • suggest-list-class : string (default = null)
    • The classname of the suggestion list.
  • aria-disabled : boolean (default = absent)
    • Value true disables the editing possibilities and closes open suggestions. Any other values or the absence of the attribute means the selector is editable.
  • role : string (default = 'listbox')
  • aria-multiselectable : boolean (default = true)
  • aria-activedescendant : string (default = null)
    • The id attribute of the currently active sd-token.
  • aria-haspopup : string (default = 'listbox')
    • Set only for multi selection mode when the selector has a listbox popup.
  • token-type : string (default = null)
    • Shown as a drag shadow suffix after the amount when moving multiple tokens. Without it the drag source is used as a drag image with an indicator from the amount of additional selected tokens.
  • drop : boolean (default = absent)
    • Present with empty value when the selector is a potential drop candidate.
  • drag-source: boolean (default = absent)
    • Present with empty value while an active dragging started from this selector.
  • case-sensitive : boolean (default = absent)
    • Based on its presence - regardless the value - the token-selector differentiates values with or without case sensitive checking.
    • Applies to typed values as well as to pasted and dropped tokens. Without it, a pasted or dropped token selects the item with the same caption, or else one whose caption differs only in case.
  • keep-suggestions-on-select : boolean (default = absent)
    • When present, the suggestion popover stays open after a value was selected (by click or Enter), so multiple suggestions can be picked in a row. The entered search term is kept as the active filter.
    • As the popover only offers not-yet-selected tokens, the selected one disappears from the list, and the popover still closes automatically once no suggestion is left. Escape, Tab and clicking outside close it as usual.

Properties - Token-Selector

  • selectionMode : string (default = "multi")
    • Reflects the corresponding attribute.
  • items : array (default = empty)
    • The data to be used by the token-selector.
    • remove-only
      • The passed items are directly visualized as tokens
    • multi select
      • The passed items are used as the datasource of the token-selector.
      • Based on this datasource, tokens are visualized when selectedIndexes are present.
      • In addition the datasource is used for the token suggestions, which will be shown when the user starts typing.
  • selectedIndexes : array (default = empty)
    • The indexes of the currently selected items.
    • Only relevant when the selection mode is multi
  • placeholder : string (default = null)
    • Reflects the corresponding attribute.
  • suggestListClass : string (default = null)
    • Reflects the suggest-list-class attribute.
  • disabled : boolean (default = false)
    • Reflects the aria-disabled attribute.
  • tokenGenerator: Default value is the one from the token element.
    • Tokens can be further customized in addition to the regular properties.
  • autoSuggestItemGenerator: Default value is the one from the list-item element.
    • Auto suggest items can be further customized in addition to the regular properties.
  • tokenType : string (default = null)
    • Reflects the token-type attribute.
  • caseSensitive : boolean (default = null)
    • Reflects the case-sensitive attribute.
  • keepSuggestionsOnSelect : boolean (default = false)
    • Reflects the keep-suggestions-on-select attribute.
  • suggestionFilter: Function (searchTerm: string, allTokens: TokenData[]) => TokenData[]
    • A custom filter function can be passed to override the default caption based search of suggestions.
  • suggestionDebounceDelay : number (default = 200)
    • Milliseconds after the last keystroke before the suggestions open.
  • isIdle : boolean (read-only)
    • True while neither the debounced opening of the suggestions nor an element update is pending.

In addition it allows to inject elements with slot named additional-content that is shown right after the tokens part.

Attributes/properties - delegated to the internal sd-input

  • placeholder : string (default = null)
  • inputLabel : string (default = null)
  • validationMessage : string (default = null)
  • validationIconSrc : string (default = null)
  • validationLevel : string (default = null)

For declarative usage, the camelCase properties map to the attributes input-label, validationmessage, validationiconsrc and validationlevel.

The embedded sd-input's CSS custom properties (e.g. --sd-input-validation-message-minheight, --sd-input-wrapper-background-color) work as well: custom properties inherit into the shadow tree, so setting them on the sd-token-selector (or any ancestor) tunes the internal input.

Attributes - Token

  • value : string (default = "")
    • The displayed value of the token.
  • type : string (default = "")
    • The type of the token. Used to mark tokens by usecases.
  • aria-disabled : boolean (default = false)
    • Indicates if the token can be edited or removed for example. An edited token may provide a delete button as well.
  • aria-current : boolean (default = false)
    • Indicates if the token is the active descendant of the relevant sd-token-selector.
  • aria-checked : boolean (default = false)
    • Indicates if the token is checked for potentially batch actions like removal or drag and drop.
  • aria-selected : boolean (default = true)
  • Set to true initially since every visible token element in a sd-token-selector can be considered as selected. The non-selected ones are not present in the DOM normally.

Properties - Token

  • value, type
    • Reflect the corresponding attributes.
  • icon: string (default = "")
    • Defines the icon url. If present the icon is shown at the start of the token.
  • iconPlaceholder : string (default = "")
    • Defines the placeholder icon of the token
  • iconBackgroundColor: string (default = "")
    • Defines the background color of the icon container. Only relevant when the icon has a transparent background.
  • statusIcon: string (default = "")
    • Defines the url of a small status icon (12px) overlaid on the bottom-right corner of the token's icon.
    • Only shown when icon or iconPlaceholder is present. The default token generator populates it from the item's statusIcon field.
  • disabled
    • Reflects the aria-disabled attribute.
  • current
    • Reflects the aria-current attribute.
  • checked
    • Reflects the aria-checked attribute.
    • A disabled token cannot be checked: disabling a checked token unchecks it.

In addition it allows to inject elements with slots named before-icon & after-icon.

CSS Custom Properties & parts

  • --sd-token-icon-background-color
    • Defines the icon background color of the token.
  • --sd-token-icon-border-radius
    • Defines the border radius of the icon of the token.
  • --sd-token-icon-height
    • Defines the height of the icon of the token.
  • --sd-token-icon-margin
    • Defines the margin of the icon of the token.
  • --sd-token-icon-width
    • Defines the width of the icon of the token.
  • remove-only-placeholder part
    • Applies to the placeholder text which is shown when the selector has no selection in remove-only mode.
  • icon part of tokens
    • Applies to the icon element within the wrapper around it that defines the iconBackgroundColor for example.

Custom Events

  • sd-token-selector-token-clicked
    • Dispatched when a token is clicked.
    • Contains the index of the token in the items list and the referenced HTML Element.
  • sd-token-selector-tokens-removed
    • Dispatched when the remove button of a token is clicked or checked tokens are removed via keyboard.
    • Contains the indexes of the removed tokens in the items list.
    • Contains also an updated list of selectedIndices if the selection-mode is multi.
  • sd-token-selector-tokens-selected
    • Dispatched when an existing and not yet selected token was selected.
    • Contains the indexes of the selected tokens in the items list and the updated selectedIndices.
  • sd-token-selector-token-created
    • Dispatched when a not existing token value was submitted.
    • Contains the value of the new token.
  • sd-token-selector-auto-suggest-initialized
    • Dispatched when the auto suggest popover is shown for the first time.

Focus ring

The token-selector does not draw focus rings itself — they are drawn by @cas-smartdesign/focus-ring (an optional peer dependency). Install it once per application, not per component:

import { FocusRing } from "@cas-smartdesign/focus-ring";

FocusRing.install();