Trend Chip
FreeA small pill that shows a change: a glyph for the direction and a label, in green, red or grey.
npx wunderui-cli add trend-chipPlayground
Installation
npx wunderui-cli add trend-chipWrites the source into your project with its dependencies and, on first use, the styles - see Installation.
Then import what you need:
import { TrendChip, TrendCaret } from "@/components/wunderui/trend-chip"
import type { TrendChipIcon } from "@/components/wunderui/trend-chip"Then use it:
import { TrendChip } from "@/components/ui/trend-chip"
export function RevenueChange() {
return <TrendChip value="+12.4%" direction="up" />
}Expected result: A small green pill with a rising trend line and +12.4%.
When to use
Use Trend Chip for
- The change of a figure in a table cell, a card header or a list row
- A percentage, a number of points or an amount that went up or down since a reference
- A compact pill where the figure itself sits in your own markup
Use something else for
- Number Value for a headline figure with its change as one unit
- Badge for a status or a count, such as Paid or 3 new
- Meter for a figure measured against a limit, such as storage used
Icon
The glyph names the direction. The same glyph turns for a fall, so a column of chips keeps one style; choose one style per screen.
Value
The label is any string, so the sign and unit come with it: +12.4%, -1.8 pts, +$1,204. The glyph is decorative, so the text has to carry the direction.
Behavior and motion
What the chip renders and how it reads.
- Static
- TrendChip isn't interactive, with no focus, hover state or handlers. Wrap it in your own link or button where the change should open something.
- Colour follows the sentiment
- By default a rise is green and a fall is red. Positive makes the chip green and negative red whatever the direction, neutral makes it grey, and the glyph always follows the direction, not the colour.
- Neutral
- A neutral direction shows a minus and, on auto, a grey chip, and the icon choice has no effect on it. Flat is the old name for neutral.
- Glyphs
- The icon picks one of seven glyphs. For down, the same glyph turns: the trend line mirrors, arrows point down, the triangle rotates 180 degrees and the circled diagonal a quarter turn.
- Size and spacing
- The pill is 20 px high with 8 px padding on the glyph side. Glyph to label is 4 px for the 12 px glyph, 6 px for 14 px circles and 8 px for 16 px arrows and the triangle.
- Reading
- A screen reader reads the label as plain text, for example +12.4%. The glyph is hidden and colour isn't announced, so the sign has to be in the string.
- Numbers
- The label isn't formatted for you. Use English format with a comma, 1,284, and add tabular figures in a column of changing values so the chips keep their width.
- Motion
- None. The chip appears as it is and doesn't animate when its value, direction or colour changes.
- Reduced motion
- There is no motion, so reduced motion changes nothing.
Anatomy
The figure shows the default chip, enlarged. The glyph, pill and colours change with the icon, direction and sentiment.
- data-slot="trend-chip"
An inline span with a glyph and a label. It isn't interactive and holds no state, so you pass the finished label, the direction and, when colour shouldn't follow direction, the sentiment.
- 1
The rounded surface, 20 px high. Its colour comes from the sentiment: green tint for positive, red for negative, grey for neutral.
- 2
One of seven icons. The same glyph turns for down and a neutral chip always shows a minus, and the glyph follows the text colour and is hidden from screen readers.
- 3
The value text in 12 px semibold. It is the only part a screen reader reads, so it carries the sign and the unit.
- Optional
The filled triangle behind the triangle icon, also used by the change label of Number Value. It is exported for your own layouts and is decorative.
Best practices
- Do
Write the sign and unit into the value: +12.4%, -3 pts, +$1,204. The glyph is hidden from screen readers, so the label is all they get.
- Do
Keep direction and meaning apart. Direction sets which way the glyph points and sentiment sets the colour: falling churn is down and positive, a rising ticket count is up and negative.
- Do
Choose one icon style per screen and keep it. The padding follows the glyph, so mixed styles in a column don't line up.
- Do
Name what the change is measured against, in the chip (+4.2% vs last month) or in the text beside it. A change without a reference says little.
- Don’t
Don't leave sentiment on auto for a metric where a fall is good. Auto colours by direction, so a falling error rate would show red.
- Don’t
Don't rely on colour alone. Green and red don't reach everyone, so the sign in the label and the glyph direction say the same thing.
- Don’t
Don't use it for a status or a count. A chip shows a change, so for a state such as Paid or Failed use Badge.
- Don’t
Don't use flat as a direction in new code. It is the old name for neutral.
API reference
One table per part. TrendChip and TrendCaret are plain components, so these tables list every prop.
An inline span with a glyph and a label. It isn't interactive and holds no state, so you pass the finished label, the direction and, when colour shouldn't follow direction, the sentiment.
| Prop | Type | Default | Description |
|---|---|---|---|
| value required | string | — | The label of the chip, as a finished string with its sign and unit, for example or . It is not formatted for you. |
| direction | "up" | "down" | "neutral" | "flat" | "up" | Which way the glyph points. shows a minus and ignores ; is the old name for . Defaults to . |
| icon | TrendChipIcon | "arrow-diagonal" | The glyph: , , , , , or . The same glyph turns for . Defaults to . |
| sentiment | "auto" | "positive" | "negative" | "neutral" | "auto" | Whether the change is good or bad, which sets the colour. colours by direction: up green, down red, neutral grey. Use for a fall that is good and for a rise that is bad. It does not change the glyph. Defaults to . |
| className | string | — | Extra classes for the pill, for example in a column of figures or a different gap. |
The filled triangle behind the triangle icon, also used by the change label of Number Value. It is exported for your own layouts and is decorative.
| Prop | Type | Default | Description |
|---|---|---|---|
| down | boolean | — | Turns the triangle 180 degrees so it points down. Defaults to false. |
| large | boolean | — | Draws the 14 px caret of Number Value instead of the 16 px caret of the chip. Defaults to false. |
| className | string | — | Extra classes for the SVG, for example a colour from the text roles. |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("trend-chip")npx wunderui-cli add trend-chipThe full library index for assistants is at /llms.txt.