Icons
Draws the 324 icons of Heroicons v2 (MIT) in outline and solid styles.
zb:icon zubazar/ui · free (MIT)
Basic usage
Pick an icon with name; the names are in the gallery at the end of the page.
<div class="flex flex-wrap items-center gap-5">
<zb:icon name="home" />
<zb:icon name="map-pin" />
<zb:icon name="truck" />
<zb:icon name="users" />
<zb:icon name="document-text" />
</div>
| Prop | Values |
|---|---|
name | Heroicons name (e.g. map-pin, truck) |
Sizes
size is a Tailwind size-* value: 4 is 16px, 5 is 20px, 6 is 24px and 8 is 32px.
<div class="flex flex-wrap items-end gap-5">
<zb:icon name="bell" size="4" />
<zb:icon name="bell" />
<zb:icon name="bell" size="6" />
<zb:icon name="bell" size="8" />
<zb:icon name="bell" size="10" />
</div>
| Prop | Values |
|---|---|
size | 4 | 5 | 6 | 8 | 10 … |
Outline and solid
solid draws the icon in the filled style; use it for selected and active states or at small sizes.
<div class="flex flex-wrap items-center gap-5">
<zb:icon name="star" size="6" />
<zb:icon name="star" size="6" solid class="text-warning-line" />
<zb:icon name="check-circle" size="6" />
<zb:icon name="check-circle" size="6" solid class="text-success-ink" />
</div>
| Prop | Values |
|---|---|
solid | true | false |
Color
An icon takes its color from the text color; for a different color, add a class such as text-danger-ink.
<div class="flex flex-wrap items-center gap-5">
<zb:icon name="trash" size="6" class="text-danger-ink" />
<zb:icon name="check-circle" size="6" class="text-success-ink" />
<zb:icon name="exclamation-triangle" size="6" class="text-warning-line" />
<zb:icon name="bell" size="6" class="text-primary-ink" />
<zb:button size="sm"><zb:icon name="plus" size="4" />New Order</zb:button>
</div>
| Prop | Values |
|---|---|
class | text-{color}-ink · text-{color}-line · text-muted… |
Accessibility
Give an icon that carries meaning on its own a label; the icon then gets role="img" and aria-label.
<div class="flex flex-wrap items-center gap-5">
<zb:icon name="shield-check" size="6" label="Verified customer" class="text-success-ink" />
<zb:button variant="ghost" size="icon" aria-label="Print"><zb:icon name="printer" /></zb:button>
</div>
| Prop | Values |
|---|---|
label | Name read out by screen readers |
All icons (324)
<zb:icon name="home" />
<zb:icon name="home" solid />
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
name | — | — | Required. Icon name; an undefined name throws an error |
size | number | 5 | Tailwind size-* value (5 = 20px) |
solid | boolean | false | Filled style |
stroke | number | 1.8 | Stroke width (outline only) |
label | — | null | When set, role="img" and aria-label; otherwise aria-hidden |
Advanced
Stroke width
stroke sets the stroke width, in the outline style only; the default is 1.8. Thin strokes (1.2–1.5) look more balanced at large sizes, and thick strokes (2–2.5) at small sizes.
<div class="flex flex-wrap items-center gap-5">
<zb:icon name="map-pin" size="10" stroke="1.2" />
<zb:icon name="map-pin" size="10" />
<zb:icon name="map-pin" size="10" stroke="2.5" />
</div>
| Prop | Values |
|---|---|
stroke | 1.2 | 1.5 | 1.8 | 2 | 2.5 |
Developer notes
- The drawings are embedded in the package: no icon font, CDN or extra package is needed, and only the icons you use end up on the page.
- The default style is outline and the default size
5(20px); an undefined name throws an error, so typos do not go unnoticed. - The
sizeclass must be in your app's compiled CSS; if you choose a value the package never uses (e.g.20), write that class in your templates too. - Don't mix the outline and solid styles in the same list.
- Icons use
currentColor; icons inside buttons and links match their color by themselves. - Icons are hidden from screen readers by default (
aria-hidden), because there is usually text next to them. - In icon-only buttons, put the label on the button (
aria-label), not on the icon.