IconChip
A filled plate that carries a format badge, an initial, or a glyph.
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
tonecarry the format (red for PDF, green for CSV), consistently across the app. - Pass four-letter formats (
JSON,YAML) aslabellike any other; the plate widens, so don't shrinkfontSizeto 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
TxDotIndicatorfor a status dot; don't shrinkTxIconChipto 6px to fake one. - Don't override
radiuswithout a design reason; the derived ladder is the visual language.
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | number | 14 | Edge length in px; typically 14 (file badge), 18 (glyph plate), or 32 (initial plate). |
radius | number | 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. |
label | string | - | Short text such as PDF; past three characters the plate widens; the default slot wins. |
fontSize | number | - | Overrides the derived font size. |
ariaLabel | string | - | Makes the chip role="img" with this name; otherwise it is aria-hidden. |
Slots
| Name | Description |
|---|---|
default | Chip 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 tomax(7, round(size * 0.4))(14→7, 32→13); passing either overrides it. - Width equals
sizeuntillabelpasses three characters; then it follows the text, at leastsizewide withsize × 0.2padding 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 (aPDFbadge besidereport.pdf); passariaLabelonly when it is the sole carrier of the information. - The
softhairline ring is abox-shadow, not aborder, so it takes no layout space and the chip stayssizetall (a long label only widens it). neutrallooks the same under both variants (insetfill 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