Components/IconChip

IconChip

A filled plate that carries a format badge, an initial, or a glyph.

VerifiedSince 0.3.9

Usage

Sizes and Tones

14, 18, and 32px tiers, a wide label, and the circle shape.

Loading demo...

Best Practices

  • Keep file-type badges at 14px and let tone carry the format (red for PDF, green for CSV), consistently across the app.
  • Pass four-letter formats (JSON, YAML) as label like any other; the plate widens, so don't shrink fontSize to squeeze them in.
  • Use 32px with tone="ink" for initial plates; it inverts across light and dark, so don't hard-code a colour.
  • Use TxDotIndicator for a status dot; don't shrink TxIconChip to 6px to fake one.
  • Don't override radius without a design reason; the derived ladder is the visual language.

API Reference

Props

PropTypeDefaultDescription
sizenumber14Edge length in px; typically 14 (file badge), 18 (glyph plate), or 32 (initial plate).
radiusnumber | string-Corner radius, numbers in px; derived from size by default, ignored for circles.
tone'neutral' | 'ink' | 'accent' | 'green' | 'orange' | 'red''neutral'Colour role.
variant'solid' | 'soft''solid'solid fills with the tone; soft uses its tint with a 30% hairline ring.
shape'square' | 'circle''square'Plate shape.
labelstring-Short text such as PDF; past three characters the plate widens; the default slot wins.
fontSizenumber-Overrides the derived font size.
ariaLabelstring-Makes the chip role="img" with this name; otherwise it is aria-hidden.

Slots

NameDescription
defaultChip contents, usually an inline SVG or short text; overrides label.

Overview

  • Radius defaults to round(size / 4) (14→4, 18→5, 32→8) and font size to max(7, round(size * 0.4)) (14→7, 32→13); passing either overrides it.
  • Width equals size until label passes three characters; then it follows the text, at least size wide with size × 0.2 padding per side, while height, radius, and font size stay put. Slot content is not measured.
  • The chip is aria-hidden="true" by default because it nearly always repeats adjacent text (a PDF badge beside report.pdf); pass ariaLabel only when it is the sole carrier of the information.
  • The soft hairline ring is a box-shadow, not a border, so it takes no layout space and the chip stays size tall (a long label only widens it).
  • neutral looks the same under both variants (inset fill plus hairline ring).

Technologies

  • Source: packages/tuffex/packages/components/src/icon-chip/.
  • Adapted from Beautiful UI, © 2026 Shane Levine, MIT; variant="soft" is an addition.
查看源码
packages/tuffex/packages/components/src/icon-chip/index.ts