Repository navigation
Closed
Labels
enhancementNew feature or request
Milestone
Description
Spec
A chip/tag component for displaying entities inline. Used standalone for tags/labels and composed by XDSTokenizer for multi-select inputs.
API
type XDSTokenColor =
| "default"
| "red" | "orange" | "yellow" | "green" | "teal"
| "cyan" | "blue" | "purple" | "pink" | "gray";
interface XDSTokenProps {
/** Text displayed in the token (required) */
label: string;
/** Color variant */
color?: XDSTokenColor; // default: "default"
/** Icon before the label */
icon?: ReactNode;
/** Whether the token is disabled */
isDisabled?: boolean;
/** Shows X button. Called when remove is activated. */
onRemove?: (event: MouseEvent | KeyboardEvent) => void;
/** Click handler. Makes the token interactive/clickable. */
onClick?: (event: MouseEvent) => void;
/** Link href. Makes the token a link. */
href?: string;
/** Description text below the label */
description?: string;
/** Content after the label, before the remove button (e.g., badge) */
endContent?: ReactNode;
/** Hide the label (icon-only token) */
isLabelHidden?: boolean;
/** StyleX overrides (margins) */
xstyle?: StyleXStyles;
/** Test ID */
"data-testid"?: string;
}Usage
// Basic
<XDSToken label="React" />
// With color and remove
<XDSToken label="Bug" color="red" onRemove={() => removeTag("bug")} />
// Clickable
<XDSToken label="Alice" icon={<XDSAvatar ... />} onClick={() => showProfile("alice")} />
// Link
<XDSToken label="Issue #42" href="/issues/42" color="blue" />
// With end content
<XDSToken label="Priority" endContent={<XDSBadge label="3" />} />Visual design
- Pill shape (rounded corners)
- Background uses non-semantic color tokens:
--color-{name}-background - Text uses
--color-{name}-text - Border uses
--color-{name}-border - Default color uses
--color-deemphasizedbackground - Interactive tokens show hover/press states
- Disabled: 50% opacity, not-allowed cursor
- Remove button (X): appears when
onRemoveis provided
Color tokens used
| Color | Background | Text | Border |
|---|---|---|---|
| default | --color-deemphasized |
--color-text-primary |
none |
| red | --color-red-background |
--color-red-text |
--color-red-border |
| blue | --color-blue-background |
--color-blue-text |
--color-blue-border |
| ... | --color-{name}-background |
--color-{name}-text |
--color-{name}-border |
Accessibility
- Interactive tokens (
onClick/href):role="button"or<a>, focusable - Remove button:
aria-label="Remove {label}" - Disabled:
aria-disabled="true" - Non-interactive: no role, just display
Design decisions
| Decision | Choice | Rationale |
|---|---|---|
| Non-semantic colors | 10 colors from token palette | Matches internal pattern, covers tag/category use cases |
No highlighted variant |
Removed | Only used for tokenizer focus state, handle internally |
onRemove shows X |
If provided, X button appears always | Skip hasRemoveOnHover (17 internal usages vs 6k total) |
onClick + href both supported |
~700 onClick + ~200 href internally | Significant usage of interactive tokens |
Depends on
- Non-semantic color tokens already exist in
tokens.stylex.ts
Used by
- XDSTokenizer (Tokenizer #82) — renders selected items as tokens
External comparison
| Capability | XDSToken | Chakra Tag | Mantine Badge / Pill | MUI Chip | Ant Tag |
|---|---|---|---|---|---|
| Component model | Single <XDSToken> |
Compound: Tag.Root > Tag.Label, Tag.StartElement, Tag.EndElement, Tag.CloseTrigger |
Badge (display) + Pill (removable, input-oriented) |
Single <Chip> |
Single <Tag> |
| Label | label (required string) |
Tag.Label child |
children |
label |
children |
| Color | color — 10 named + "default" |
colorPalette — any palette token |
color — any theme color; variant — filled / light / outline / gradient |
color — "default" / "primary" / "secondary" / "error" / "info" / "success" / "warning" |
color — preset names or hex string |
| Icon | icon (ReactNode, start) |
Tag.StartElement / Tag.EndElement (composition) |
leftSection / rightSection |
icon (start), deleteIcon (end) |
icon |
| Remove / close | onRemove callback → shows X |
Tag.CloseTrigger child |
Pill with withRemoveButton + onRemove |
onDelete callback → shows delete icon |
closable boolean + onClose callback |
| Clickable | onClick prop |
onClick on root |
Polymorphic component prop |
onClick + clickable boolean |
Wrap children in <a> |
| Link | href prop |
Polymorphic as="a" |
Polymorphic component="a" |
component="a" + href |
Wrap in <a> child |
| End content | endContent (ReactNode) |
Tag.EndElement (composition) |
rightSection |
deleteIcon (limited to icon) |
Not supported |
| Disabled | isDisabled |
disabled on root |
Not built-in | disabled |
Not built-in |
| Sizes | Not in v1 (single size) | size (sm/md/lg) |
size (xs–xl) |
size (small/medium) |
Not built-in |
| Styling escape | xstyle (StyleX only) |
css / Panda |
classNames / styles (Styles API) |
sx / className |
className / style |
| Hidden label | isLabelHidden |
Not built-in | Not built-in | Not built-in | Not built-in |
Key takeaways:
- Chakra v3 uses compound composition (
Tag.Root > Tag.Label); all others use flat prop APIs like XDSToken. - Mantine splits the concept:
Badgefor display,Pillfor removable tags inside inputs — XDSToken covers both. - MUI Chip requires an explicit
clickableboolean; XDSToken infers interactivity fromonClick/href. endContentas a generic ReactNode slot is unique to XDSToken — MUI limits the end slot to a delete icon, Ant has no end slot.isLabelHidden(icon-only token) is not offered by any compared library.
Internal usage data
~6,000+ total usages of XDSToken across the internal codebase.
| Prop | Count | % of total | Notes |
|---|---|---|---|
label |
3,427 | ~57% | Required prop — gap from 6k suggests some legacy patterns without explicit label |
icon |
1,462 | ~24% | Nearly 1 in 4 tokens has an icon (often avatars for people tokens) |
onClick |
948 | ~16% | Interactive / clickable tokens |
endContent |
623 | ~10% | Badge counts, status indicators, etc. |
onRemove |
557 | ~9% | Removable tokens (most via XDSTokenizer composition) |
href |
527 | ~9% | Link tokens — combined with onClick, ~25% of tokens are interactive |
Color distribution:
| Color | Count |
|---|---|
| blue | 22 |
| green | 22 |
| red | 19 |
| purple | 7 |
| yellow | 5 |
- Total colored tokens: 75 out of 6,000+ (~1.2%). The vast majority use the default color.
- Blue, green, and red account for 84% of colored usage — confirms these are the most important non-default colors.
- Low overall color usage validates the decision to keep color optional with a sensible default.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
czarandy commentedon Feb 13, 2026
one annoying thing with XDSToken is it has built-in margin which makes it awkward to use outside of XDSTokenizer
we should make sure to avoid that
[-]Tokens[/-][+]XDSToken component[/+]feat(Token): add XDSToken component
feat(Token): add XDSToken component