Luke UI includes one icon set. All the icons have the same weight, and all use a 24 by 24 grid. The
Luke UI stylesheet draws them, so Icon needs no setup beyond the stylesheet import. The stylesheet
loads each icon from a data: URL. If your application sets a Content Security Policy, see
Installation.
Import Icon and give it a name from the set. The name prop accepts only the names in the gallery
above. The compiler rejects any other name. iconNames lists the names in no guaranteed order. See
Icon for the component API.
Set size to xsmall, small, medium, or large. These sizes currently map to 16, 20, 24, and
32 CSS pixels at a 16px root. They use rem and scale with the root font size.
Controls size the icons inside them, so an icon in a control needs no size. A Button and an Icon
Button use xsmall. A field control uses xsmall at the small control size and small at
medium. Elsewhere, the default size is medium.
To give a group of icons the same size, set the --luke-icon-size custom property on an element
around them. iconSizeVars(size) returns that property for one of the four sizes. Pass the result
to the element's style, or to the vars of a Vanilla Extract style. The nearest element that sets
the property wins, so an inner group can use another size. An icon that has its own size keeps
that size. Loading Spinner takes its size the same way.
An icon takes the colour of the text around it, including the readable colour a Luke UI background
sets. To change the colour of an icon, wrap it in a Text
with a color, as in this example.
An icon that gives information must have a contrast ratio of 3 to 1 or more against its background.
An icon that only decorates adjacent text has no contrast requirement.
The icon is decorative when the text next to it gives the meaning. Do not give it a title. The
component then hides the icon from assistive technology.
Use createIcon to make a component for a symbol that the set does not include. The new component
gets the same size behaviour and accessibility behaviour as Icon. See
Icon.