Data display

Icon

An SVG icon from any Iconify collection, rendered inline on the server, so it takes the current text color and needs no JavaScript or icon font. It also shows an image from a URL, or any content in the slot, at the same size.

Blade

A 24px house icon in the color of the surrounding text. A name without a collection (home) is looked up in the collections of tallkit.icon.collections, in order (mdi first): home is mdi:home. The icon is decorative: hidden from screen readers.

From a specific collection #

collection:name picks the icon from that collection, as named on Iconify. Classes go to the <svg>, so color and size utilities apply directly.

Blade

An icon that means something #

The first shows "Delete" in a tooltip on hover and on keyboard focus (it becomes focusable for that), and the text is also its accessible name. The second is announced as an image named "Favorite". Give a name to any icon that conveys information not written next to it.

Blade

An image or any content #

An absolute URL (starting with https:// or another scheme) is shown as an image, cropped to the icon size; a path such as /logo.png is read as an icon name, so pass it in image instead. Without a name, the slot is rendered in place of the icon.

🎉
Blade

Icon alias #

icon is an alias of name.

Blade

Sizes #

size sets the width and height, from xs to 3xl.

Blade

Colors #

Classes go to the <svg>, so text color utilities apply directly.

Blade

Label and tooltip #

With both aria-label and tooltip, the label names the icon and the tooltip describes it.

Blade

Livewire state #

The icon name can come from component state, here toggled by a button.

Blade

Customization #

Tooltip options take the tooltip: prefix, such as tooltip:position.

Blade

Reference

tk:icon

Prop Type Default Description
name string null The icon: name, collection:name, or an image URL.
icon string null Same as name, for when name is taken by another attribute.
size string md xs, sm, md, lg, xl, 2xl or 3xl. Sets the width and height.
tooltip string | slot null A tooltip, translated. On an icon with no aria-label, it is also the accessible name.
image string from name An image URL, in place of a name.
svg string from name SVG markup to render as is, in place of a looked-up icon.

Slots

Slot Description
default Content rendered in place of the icon when there is no name, image or svg.

Customization

Classes and attributes go to the <svg> (or the <img>). Tooltip options take the tooltip: prefix (tooltip:position, tooltip:delay...).

blade

Accessibility

An icon with no tooltip and no aria-label is decorative: aria-hidden="true" and focusable="false" on the <svg>, alt="" on an image. With a tooltip or an aria-label it has role="img" and an accessible name; with both, the aria-label names it and the tooltip describes it. An icon with a tooltip gets tabindex="0" and a focus outline, so keyboard users can open the tooltip.

Behavior notes

  • Icons are looked up once and kept. For each collection the name can come from (the one in collection:name, or each of tallkit.icon.collections in order for a name without one), the icon is taken from storage/app/tallkit/icons or from the icons the package ships with; the next collection is tried only once this one is known not to have the icon. Otherwise the icon is asked to the Iconify API, and the answer is saved to that folder. The API is called after the response is sent, so a new icon renders nothing on that page and shows on the next load. With tallkit.icon.fetch set to false the API is never called while rendering, and only php artisan tallkit:icons fetches icons. Run that command at deploy to fetch every icon the views use ahead of time.
  • Write names with their collection (mdi:home): the package views and the icons it ships with use them, so such a name renders a shipped icon at once, with no network. A name without one walks the configured collections and may wait for a fetch.
  • A name that is not found renders nothing, and is not asked for again for a day (tallkit.icon.missing_ttl).
  • The collections tried for a name without one are set in config('tallkit.icon.collections'). Changing them looks the names that were missing up again.
  • Icons saved by an older version under names without a collection are not used: run php artisan tallkit:icons after updating so they are fetched again under their full names.
  • An SVG from Iconify or from the icons folder is sanitized before it is stored or rendered: scripts, <style> elements, event attributes and external references are removed. The svg prop is rendered as is.