Skip to content

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.

SizeThe button's classDrawn atButtons
xs
size-2.510px
10px
sm
size-312px
16px
default
size-3.514px
16px
lg
size-416px
16px

Beside 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

A button that holds only an icon is square: 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

In a field the icon goes in an InputGroupAddon, which sets its size and draws it in the secondary text colour.
In a menu row the icon comes first, with no attribute. Foundation draws it at 16px in --muted-foreground, so the label leads; a destructive row keeps its own colour.
v4.2.0Changelog
A badge takes the same 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.

Press it. Off, the star is the stroke icon. On, it is the fill icon of the same name, so the state shows in the shape and not in colour alone.
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" and focusable="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-only text when the words must not show.
  • A state is never told by an icon's colour alone: the shape changes, or words do.