Icons
The icon set the Registry uses, how to import an icon and how it sits beside a label.
Every icon in the Registry comes from one set: the stroke icons of the npm package
@keyline-icons/react. An icon is drawn in the current text colour, so it takes the
colour of the label beside it. No other icon library is used.
Importing
Import an icon by its name, which ends in Icon.
import { PlusIcon } from "@keyline-icons/react"
export function AddButton() {
return (
<Button>
<PlusIcon data-icon="inline-start" />
New project
</Button>
)
}Inside a control an icon needs no size: the control sets it. Anywhere else, give it a
size-* class, as in <PlusIcon className="size-4" />. A control leaves an icon with a
size-* class of its own alone.
The set in use
The package holds many more icons than these. These are the ones the Registry's own components import. Press a name to copy it.
In a button
Foundation draws the icon of a button at 16px, whatever the button's own class asks for. It leaves one button alone, which keeps its own size: a button with the class size-5 or h-5.
xssize-2.510pxsmsize-312pxdefaultsize-3.514pxlgsize-416pxBeside a label
An icon beside a label says which side it is on with data-icon, and the button draws
that side in a little.
- A button's text sits 8px from each edge (
px-2). data-icon="inline-start"on the icon, before the label: the padding on that side becomes 6px.data-icon="inline-end"on the icon, after the label: the padding on that side becomes 6px.- The icon and the label are 6px apart.
Alone
size="icon" is 30px a side on a desktop. It has no text, so aria-label says what it does.<Button size="icon" variant="outline" aria-label="Archive the project">
<ArchiveIcon />
</Button>In other controls
InputGroupAddon, which sets its size and draws it in the secondary text colour.--muted-foreground, so the label leads; a destructive row keeps its own colour.data-icon="inline-start" and data-icon="inline-end" as a button, and sets the size of its icon itself.Stroke and fill
The stroke icon is the one to use. The fill icon of the same name comes from
@keyline-icons/react/fill and has a single use: an on-state that has to read as a
different shape. Import it under a name that ends in FilledIcon.
import { StarIcon } from "@keyline-icons/react"
import { StarIcon as StarFilledIcon } from "@keyline-icons/react/fill"
<Toggle
variant="outline"
aria-label="Star the project"
pressed={starred}
onPressedChange={setStarred}
>
{starred ? <StarFilledIcon /> : <StarIcon />}
</Toggle>Accessibility
- Every icon renders with
aria-hidden="true"andfocusable="false"on its<svg>, so assistive technology passes over it. An icon beside a label that says the same thing is decorative, and needs nothing more. - An icon alone in a button or a toggle gives the control no name. The control takes
aria-label. - An icon that means something with no control round it, such as a status mark, has its
meaning in text beside it. Use
sr-onlytext when the words must not show. - A state is never told by an icon's colour alone: the shape changes, or words do.