EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
Token·component·@astryxdesign/core

Token

Token is a small, inline element for representing discrete pieces of associated data, like tags, categories, or selections. Use it to label content, show active filters, or represent removable items like selected recipients in a compose field.

Open in Playground @astryxdesign/core/Token

Showcases and examples

6 documented examples

Token

Token API entry

Preview loads on approachPreview loads on approach
Exact source · token-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {Token} from '@astryxdesign/core/Token';
import {Icon} from '@astryxdesign/core/Icon';
import {Stack} from '@astryxdesign/core/Layout';
import {TagIcon} from '@heroicons/react/24/outline';

export default function TokenShowcase() {
  return (
    <Stack direction="horizontal" gap={2} vAlign="center">
      <Token label="Default" />
      <Token label="Removable" color="blue" onRemove={() => {}} />
      <Token
        label="Design"
        color="purple"
        icon={<Icon icon={TagIcon} size="sm" color="inherit" />}
      />
    </Stack>
  );
}

Usage

Token is a small, inline element for representing discrete pieces of associated data, like tags, categories, or selections. Use it to label content, show active filters, or represent removable items like selected recipients in a compose field.

  • Use color to distinguish categories (for example, green for "Active", red for "Blocked", blue for "In Review") so users can scan status at a glance.
  • Provide an onRemove callback when tokens represent user selections that can be undone, like filters or multi-select values.
  • Add a leading icon when it helps identify the token type faster, like a person icon for user tokens or a tag icon for labels.
  • Keep labels short: one to three words. Tokens truncate with ellipsis when the text overflows.
  • Don't use tokens for primary actions or navigation; use Button or Link instead. Tokens are for displaying metadata, not triggering workflows.
  • Don't hide the label unless the icon alone is universally understood. A color dot without text is ambiguous.
  • Don't mix too many colors in one token group. Stick to two or three meaningful colors so the palette stays scannable.

Typed props

PropType and behavior
labelstring · required
Text label displayed inside the token.
size'sm' | 'md' | 'lg' · default 'md'
The size of the token.
color'default' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'cyan' | 'blue' | 'purple' | 'pink' | 'gray' · default 'default'
Color variant of the token.
iconReactNode
Optional icon rendered before the label.
Slot: Icon
isDisabledboolean · default false
Whether the token is disabled; reduces opacity and blocks interactions.
onRemove(e: React.MouseEvent) => void
Callback fired when the remove button is clicked. When provided, an X button is rendered inside the token.
onClick(e: React.MouseEvent) => void
Click handler. When provided, the token renders as a <span> container with an invisible <button> inside for accessibility.
hrefstring
Link URL. When provided, the token renders as an <a> element. The destination follows the shared navigation rule described on the Link href prop.
descriptionstring
Accessible description applied via aria-description on the root element.
endContentReactNode
Content rendered after the label and before the remove button.
Slot: Icon, Badge
isLabelHiddenboolean · default false
Visually hides the label using a screen-reader-only clip technique; the label remains accessible.
xstyleStyleXStyles
StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value, not an inline style object like style={{}}.

Anatomy

Icon · optional

A leading icon that identifies the token type, like a user avatar or category symbol.

Label · required

The visible text. Also used as the accessible name when isLabelHidden is true.

End content · optional

Trailing content after the label, like a count badge or status dot.

Remove button · optional

An X button that appears when onRemove is provided, letting users dismiss the token.

Theming

Targets

astryx-token

Visual props: color, size