v0.0.2
Demos (demo panel, opens in a new tab)

Icons

Draws the 324 icons of Heroicons v2 (MIT) in outline and solid styles.

zb:icon zubazar/ui · free (MIT)

Basic usage

Basic usage: view
BLADE

Pick an icon with name; the names are in the gallery at the end of the page.

blade
<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>
PropValues
nameHeroicons name (e.g. map-pin, truck)

Sizes

Sizes: view
BLADE

size is a Tailwind size-* value: 4 is 16px, 5 is 20px, 6 is 24px and 8 is 32px.

blade
<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>
PropValues
size4 | 5 | 6 | 8 | 10 …

Outline and solid

Outline and solid: view
BLADE

solid draws the icon in the filled style; use it for selected and active states or at small sizes.

blade
<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>
PropValues
solidtrue | false

Color

Color: view
BLADE

An icon takes its color from the text color; for a different color, add a class such as text-danger-ink.

blade
<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>
PropValues
classtext-{color}-ink · text-{color}-line · text-muted…

Accessibility

Accessibility: view
BLADE

Give an icon that carries meaning on its own a label; the icon then gets role="img" and aria-label.

blade
<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>
PropValues
labelName read out by screen readers

All icons (324)

All icons (324): view
BLADE
blade
<zb:icon name="home" />
<zb:icon name="home" solid />

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
name— — Required. Icon name; an undefined name throws an error
sizenumber5Tailwind size-* value (5 = 20px)
solidbooleanfalseFilled style
strokenumber1.8Stroke width (outline only)
label—nullWhen set, role="img" and aria-label; otherwise aria-hidden

Advanced

1 example

Stroke width

Stroke width: view
BLADE

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.

blade
<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>
PropValues
stroke1.2 | 1.5 | 1.8 | 2 | 2.5

Developer notes

Events, hooks and details
  • 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 size class 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.
Zubazar UI · ZubazarDesigned for people.