Layout

Element

The building block behind buttons, links, badges, headings and texts: a label with an icon, a prefix, a suffix, a trailing icon, a badge and a keyboard hint around it, rendered as a <span>, a link or a button. Use it directly for an inline item that needs those parts but none of the styling of the higher-level tags.

tk:element.wrapper renders a tk:element only when something would show, and nothing otherwise.

Due tomorrow 2 tasks
Blade

A <span> with a calendar icon, the text "Due tomorrow" and a small muted "2 tasks" after it, side by side and vertically centered.

With href (or route) the element is an <a> that navigates with wire:navigate, and gets aria-current="page" and data-current while its URL is the current page. With action (or type) it is a <button type="button"> that calls the Livewire method on click. The first shows a badge with 12 after the label; the second, an E key hint.

Inbox 12 Archived: 0
Blade

Rendering only when there is something to show #

When $user->nickname is empty nothing is rendered, not even an empty <span>; otherwise the same <span> as tk:element. Any other part with content, such as an icon, makes it render too.

Ada
Blade

Parts around the label #

prefix and suffix are muted texts, icon-trailing an icon after the label, badge a small badge, kbd a keyboard hint and icon-dot a dot over the icon (with a count when given a value).

$ 120.00 /month Projects Inbox 12 Search ⌘K Alerts 3 Mentions
Blade

external opens the link in a new tab, without wire:navigate; a disabled link has no href and gets aria-disabled.

Tooltip and info #

tooltip shows a hint on hover and names an icon-only element; info adds a help icon after the label with its own tooltip.

Storage
Blade

Rendering from data #

A list of folders from an array, each with its icon and a badge only when it has a count.

Prepend, append and slots #

prepend and append sit at the outer ends, and any part takes a slot with markup in place of the prop.

AS Order #1042 Paid Ana replied
Blade

Customization #

Classes go to the element; prefixed attributes reach the parts (icon:, suffix:, badge:...). content: wraps the label in a <span> of its own.

Featured projects of the quarter 8
Blade

Reference

tk:element
tk:element.wrapper

tk:element

Prop Type Default Description
as string span The tag to render. href turns it into a, and type or action into button.
href string null The link URL. javascript:, vbscript: and data: URLs are dropped.
route string null A route name, turned into href.
parameters array null The route parameters.
external bool | string false Opens the link in a new tab (target="_blank") and turns off wire:navigate. A string is used as the target. target="_blank" on the tag has the same effect.
navigate bool auto wire:navigate on the link. On by default, except for external links and links to a file (.pdf, .zip...). true forces it, false turns it off.
current bool | string from the URL Marks the link as the current page. true sets aria-current="page", a string sets that value (step, location...), false never marks it.
exact bool false Counts the link as current only on its own URL, not on the pages under it.
matchQuery bool true Compares the query string of href too, when it has one.
type string button The button type, for a <button>.
action string null A Livewire method called on click, as wire:click. Makes the element a button.
tooltip string | slot null A tooltip, translated. On a link or button with no text it is the accessible name too.
ariaLabel string | bool from the label The accessible name. On a link or button it defaults to label, or to the tooltip when there is no label and no slot content. false leaves it out.
info string | slot null A help icon after the label, with this text as its tooltip. Replaces iconTrailing.
kind string null Adds data-tallkit-<kind> to the element, for styling and for scripts. Used by the components built on it.

Also accepts the element props: prepend, icon, iconDot, prefix, label, suffix, iconTrailing, badge, kbd, append.

Slots

Slot Description
default The content, in place of label.
iconEmpty Content in the place of the icon, shown only when there is no icon.
iconTrailingEmpty Content in the place of the trailing icon, shown only when there is no iconTrailing and no info.

Prefixes

Prefix Goes to
icon: The icon.
icon-wrapper: The element around the icon, when it has an iconDot.
icon-dot: The dot over the icon.
content: A <span> wrapping the label, added only when this prefix is used.
prefix: The prefix text.
suffix: The suffix text.
icon-trailing: The trailing icon.
info: The help icon.
badge: The badge.
kbd: The keyboard hint.
tooltip: The tooltip options: tooltip:position, tooltip:align, tooltip:delay, tooltip:kbd, tooltip:open (click to open it on a click instead of on hover, manual)... A tooltip:kbd written as a shortcut (mod.k) shows the keys of the user's platform, as Kbd does.

tk:element.wrapper

Takes the same props as tk:element and passes them on. It renders when the slot or any of label, icon, prefix, suffix, iconTrailing, info, badge, prepend, append or kbd has content.

Slots

Slot Description
default The content, in place of label.

Slots

icon, prefix, label, suffix, iconTrailing, badge and kbd also accept a slot with any markup.

Customization

Classes and attributes on the tag go to the element itself. Each part takes attributes through its prefix (listed in the Reference above).

blade

Accessibility

A link is a real <a> and an action a real <button>, so neither needs a role. A disabled link (disabled with href) has no href and carries role="link" and aria-disabled="true". The current page link gets aria-current. The tooltip is linked with aria-describedby, unless it repeats the accessible name. An element with only an icon has no name of its own: give it a tooltip or an aria-label.

Behavior notes

  • href wins over as, and type or action win over as when there is no href.
  • A label with line breaks keeps them, as <br>.
  • On a link or a button, a text label also becomes the aria-label, so the badge, the suffix and the keyboard hint are not read as part of the name.
  • aria-current is not set on a <span> or a <p>, even when current is true.