component
Icon
One of Rost's 23 glyphs, 24px, in the colour of the text around it.
Icons/arrow-downIcons/arrow-down-leftIcons/arrow-leftIcons/arrow-rightIcons/arrow-upIcons/chevron-downIcons/chevron-leftIcons/chevron-rightIcons/chevron-upIcons/desktopIcons/dotIcons/down-rightIcons/dragIcons/minusIcons/mobileIcons/plusIcons/scrollIcons/searchIcons/starIcons/lockIcons/up-leftIcons/up-rightimport { Icon } from 'rost/components/icon/Icon'
<Icon name="arrow-right" />
<Icon name="chevron-down" size="small" />
<Icon name="drag" label="Reorder" /> src/components/icon/Icon.tsx
import type { HTMLAttributes } from 'react'
import './icon.css'
export const ICON_NAMES = ['arrow-down', 'arrow-down-left', 'arrow-left', 'arrow-right', 'arrow-up', 'chevron-down', 'chevron-left', 'chevron-right', 'chevron-up', 'circle-outline', 'desktop', 'dot', 'down-right', 'drag', 'lock', 'minus', 'mobile', 'plus', 'scroll', 'search', 'star', 'up-left', 'up-right'] as const
export type IconName = (typeof ICON_NAMES)[number]
export type IconSize = 'medium' | 'small' | 'xsmall'
export interface IconProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
/** The file in `assets/icons/`, without `.svg`. */
readonly name: IconName
/** Medium is Figma's 24px; Small (20px) fits Button's and IconButton's slot. */
readonly size?: IconSize
/** What it means, when nothing next to it says so. Without it the icon is hidden from screen readers. */
readonly label?: string
}
const b = 'rost-icon'
/**
* A glyph in the colour of the text around it. Built from
* contracts/icon.contract.yaml.
*/
export function Icon({ name, size = 'medium', label, className, ...rest }: IconProps) {
const a11y = label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true }
return <span className={[b, `${b}--name-${name}`, `${b}--size-${size}`, className].filter(Boolean).join(' ')} {...a11y} {...rest} />
}
The source for everything on this page: contracts/icon.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: icon
name: Icon
kind: component
status: review
summary: One of Rost's 23 glyphs, 24px, in the colour of the text around it.
category: display
related: [ icon-button, button, illustration ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "92:15"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=92-15
extractedAt: "2026-10-30"
extractedBy: mcp
frozenAt: "2026-10-30"
props:
name:
type: enum
values: [ arrow-down, arrow-down-left, arrow-left, arrow-right, arrow-up, chevron-down, chevron-left, chevron-right, chevron-up, circle-outline, desktop, dot, down-right, drag, lock, minus, mobile, plus, scroll, search, star, up-left, up-right ]
default: arrow-right
notes: "The file in `assets/icons/`, without `.svg`. Figma calls it `icons/<name>`. `circle-outline` is a file with no frame in Figma's set."
size:
type: enum
values: [ Medium, Small, XSmall ]
default: Medium
notes: "Medium is Figma's 24px. Small (20px) is the slot Button and IconButton give an icon, XSmall (16px) the one on IconButton's Project type."
label: { type: slot, notes: "What the icon means, when nothing else says it. With a label it's `role=\"img\"`; without one it's hidden from screen readers." }
elements:
root:
notes: "A `<span>` filled with `currentColor` and cut to the icon's shape by a mask, so one file draws in any colour and follows a button's states."
styles:
display: { value: inline-block, assert: false }
vertical-align: { value: middle, assert: false }
flex-shrink: { value: "0", assert: false }
background: { value: currentColor }
mask-position: { value: center, assert: false }
mask-size: { value: contain, assert: false }
mask-repeat: { value: no-repeat, assert: false }
variants:
- when: { size: Medium }
elements:
root:
width: { token: spacing/size/small, value: 24px }
height: { token: spacing/size/small, value: 24px }
- when: { size: Small }
elements:
root:
width: { token: spacing/size/xsmall, value: 20px }
height: { token: spacing/size/xsmall, value: 20px }
- when: { size: XSmall }
elements:
root:
width: { token: spacing/size/2xsmall, value: 16px }
height: { token: spacing/size/2xsmall, value: 16px }
- when: { name: arrow-down }
elements:
root:
mask-image: { value: url(./svg/arrow-down.svg), untokenised: "The icon file, `assets/icons/arrow-down.svg`." }
- when: { name: arrow-down-left }
elements:
root:
mask-image: { value: url(./svg/arrow-down-left.svg), untokenised: "The icon file, `assets/icons/arrow-down-left.svg`." }
- when: { name: arrow-left }
elements:
root:
mask-image: { value: url(./svg/arrow-left.svg), untokenised: "The icon file, `assets/icons/arrow-left.svg`." }
- when: { name: arrow-right }
elements:
root:
mask-image: { value: url(./svg/arrow-right.svg), untokenised: "The icon file, `assets/icons/arrow-right.svg`." }
- when: { name: arrow-up }
elements:
root:
mask-image: { value: url(./svg/arrow-up.svg), untokenised: "The icon file, `assets/icons/arrow-up.svg`." }
- when: { name: chevron-down }
elements:
root:
mask-image: { value: url(./svg/chevron-down.svg), untokenised: "The icon file, `assets/icons/chevron-down.svg`." }
- when: { name: chevron-left }
elements:
root:
mask-image: { value: url(./svg/chevron-left.svg), untokenised: "The icon file, `assets/icons/chevron-left.svg`." }
- when: { name: chevron-right }
elements:
root:
mask-image: { value: url(./svg/chevron-right.svg), untokenised: "The icon file, `assets/icons/chevron-right.svg`." }
- when: { name: chevron-up }
elements:
root:
mask-image: { value: url(./svg/chevron-up.svg), untokenised: "The icon file, `assets/icons/chevron-up.svg`." }
- when: { name: circle-outline }
elements:
root:
mask-image: { value: url(./svg/circle-outline.svg), untokenised: "The icon file, `assets/icons/circle-outline.svg`." }
- when: { name: desktop }
elements:
root:
mask-image: { value: url(./svg/desktop.svg), untokenised: "The icon file, `assets/icons/desktop.svg`." }
- when: { name: dot }
elements:
root:
mask-image: { value: url(./svg/dot.svg), untokenised: "The icon file, `assets/icons/dot.svg`." }
- when: { name: down-right }
elements:
root:
mask-image: { value: url(./svg/down-right.svg), untokenised: "The icon file, `assets/icons/down-right.svg`." }
- when: { name: drag }
elements:
root:
mask-image: { value: url(./svg/drag.svg), untokenised: "The icon file, `assets/icons/drag.svg`." }
- when: { name: lock }
elements:
root:
mask-image: { value: url(./svg/lock.svg), untokenised: "The icon file, `assets/icons/lock.svg`." }
- when: { name: minus }
elements:
root:
mask-image: { value: url(./svg/minus.svg), untokenised: "The icon file, `assets/icons/minus.svg`." }
- when: { name: mobile }
elements:
root:
mask-image: { value: url(./svg/mobile.svg), untokenised: "The icon file, `assets/icons/mobile.svg`." }
- when: { name: plus }
elements:
root:
mask-image: { value: url(./svg/plus.svg), untokenised: "The icon file, `assets/icons/plus.svg`." }
- when: { name: scroll }
elements:
root:
mask-image: { value: url(./svg/scroll.svg), untokenised: "The icon file, `assets/icons/scroll.svg`." }
- when: { name: search }
elements:
root:
mask-image: { value: url(./svg/search.svg), untokenised: "The icon file, `assets/icons/search.svg`." }
- when: { name: star }
elements:
root:
mask-image: { value: url(./svg/star.svg), untokenised: "The icon file, `assets/icons/star.svg`." }
- when: { name: up-left }
elements:
root:
mask-image: { value: url(./svg/up-left.svg), untokenised: "The icon file, `assets/icons/up-left.svg`." }
- when: { name: up-right }
elements:
root:
mask-image: { value: url(./svg/up-right.svg), untokenised: "The icon file, `assets/icons/up-right.svg`." }
guidance:
status: proposed
use:
- title: Next to a label
text: Next to a label, when the shape says the same thing faster. An arrow on "Back", a chevron on something that opens.
show: icons/arrow-left
- title: Inside a button
text: Inside Button and IconButton, through their `icon` slot, at Small.
show: icons/arrow-right
avoid:
- title: Something to press
text: On its own as something to press. That's **IconButton**, which gives it a target and states.
- title: A picture with no job
text: A picture with no job next to words. That's an **Illustration**, which keeps its own colours.
- title: A glyph Rost lacks
text: A glyph Rost doesn't have. Add the SVG to `assets/icons/` and Figma's set first, so they stay the same list.
show: icons/dot
behaviour: |-
It takes the text colour it sits in. Figma draws them in `non-interactive/foreground/tertiary` (#999999); inside a Button it's the button's icon colour, state by state. The shapes are Figma's exports, kept as they are.
accessibility:
hidden: "Next to words that say the same, it's `aria-hidden=\"true\"`. That's the default."
labelled: "On its own and meaningful, pass `label`. It becomes `role=\"img\"` with that `aria-label`."
content: A label names what it means, not what it looks like. "Next", not "Right arrow".
Install
npx github:Runceanu/rost add icon It lands in src/rost/icon/, with what it needs and its contract. Install has the rest.
When to use
Next to a label
Next to a label, when the shape says the same thing faster. An arrow on "Back", a chevron on something that opens.
Inside a button
Inside Button and IconButton, through their
iconslot, at Small.
When not to use
Something to press
On its own as something to press. That's IconButton, which gives it a target and states.
A picture with no job
A picture with no job next to words. That's an Illustration, which keeps its own colours.
A glyph Rost lacks
A glyph Rost doesn't have. Add the SVG to
assets/icons/and Figma's set first, so they stay the same list.
Behaviour
It takes the text colour it sits in. Figma draws them in non-interactive/foreground/tertiary (#999999); inside a Button it's the button's icon colour, state by state. The shapes are Figma's exports, kept as they are.
Accessibility
- Hidden
Next to words that say the same, it's
aria-hidden="true". That's the default. - Labelled
On its own and meaningful, pass
label. It becomesrole="img"with thataria-label.
Content
A label names what it means, not what it looks like. "Next", not "Right arrow".
Props
| Prop | Type | Values | Default |
|---|---|---|---|
name | enum | arrow-down · arrow-down-left · arrow-left · arrow-right · arrow-up · chevron-down · chevron-left · chevron-right · chevron-up · circle-outline · desktop · dot · down-right · drag · lock · minus · mobile · plus · scroll · search · star · up-left · up-right | arrow-right |
size | enum | Medium · Small · XSmall | Medium |
label | slot | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
backgroundcurrentColorno token yet
displayinline-block · vertical-alignmiddle · flex-shrink0 · mask-positioncenter · mask-sizecontain · mask-repeatno-repeat
Changes by variant
26 variants. Each table is what one thing changes with: a column per size, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows size
In 3 variants
| Property | Medium | Small | XSmall |
|---|---|---|---|
root.heightspacing/size/… | small 24px | xsmall 20px | 2xsmall 16px |
root.widthspacing/size/… | small 24px | xsmall 20px | 2xsmall 16px |
Follows name
In 23 variants
| Property | Arrow-down | Arrow-down-left | Arrow-left | Arrow-right | Arrow-up | Chevron-down | Chevron-left | Chevron-right | Chevron-up | Circle-outline | Desktop | Dot | Down-right | Drag | Lock | Minus | Mobile | Plus | Scroll | Search | Star | Up-left | Up-right |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
root.mask-image | url(./svg/arrow-down.svg) | url(./svg/arrow-down-left.svg) | url(./svg/arrow-left.svg) | url(./svg/arrow-right.svg) | url(./svg/arrow-up.svg) | url(./svg/chevron-down.svg) | url(./svg/chevron-left.svg) | url(./svg/chevron-right.svg) | url(./svg/chevron-up.svg) | url(./svg/circle-outline.svg) | url(./svg/desktop.svg) | url(./svg/dot.svg) | url(./svg/down-right.svg) | url(./svg/drag.svg) | url(./svg/lock.svg) | url(./svg/minus.svg) | url(./svg/mobile.svg) | url(./svg/plus.svg) | url(./svg/scroll.svg) | url(./svg/search.svg) | url(./svg/star.svg) | url(./svg/up-left.svg) | url(./svg/up-right.svg) |