Skip to content

Button

Renders a <button type="button">, an <a role="button"> when href is set, or the element named by tag.

variant sets the color. default is Tabler’s neutral button, a plain .btn:

appearance switches between a filled background, an outline border and a ghost button that only shows its background on hover. link looks like a link (btn-link) and ignores variant:

action is a quiet, square icon button for a card header or a table row (btn-action): it ignores variant and only shows a background on hover. Give it an aria-label, and group several in ButtonActions:

icon adds an icon before the label and iconEnd one after it. They are rendered with Icon, so a name with an icon set prefix (lucide:circle-check) works with symfony/ux-icons, and get Tabler’s icon class (icon icon-end for the trailing one), which sizes and spaces them. Both are hidden from assistive technology. iconOnly removes the label padding (btn-icon): with icon, the button needs no children, but give it an aria-label (or a tooltip, which becomes its label):

The icon and iconEnd blocks replace the generated icons. You can also put the icon in the children yourself, with the icon class:

animateIcon animates the icon when the button is hovered:

modal, offcanvas and collapse take the id of the element the button opens, and set Bootstrap’s data API: data-bs-toggle, data-bs-target="#<id>" and aria-controls, plus aria-expanded="false" for collapse (Bootstrap updates it on toggle). They work on a link too: Bootstrap reads data-bs-target on an <a> and prevents its navigation; set its href to #<id> so the link still points to the target without JavaScript.

Bootstrap reads a single data-bs-toggle, so set only one of them: when several are set, modal wins over offcanvas, which wins over collapse. An attribute you pass yourself (data-bs-target=".filters", aria-expanded="true"…) wins over the generated one.

tooltip sets the title and data-bs-toggle="tooltip", which tabler.js turns into a Bootstrap tooltip. On an iconOnly button, it is also the aria-label, unless you pass one:

A trigger takes precedence: with modal, offcanvas or collapse, tooltip only sets the title, a native browser tooltip, since the button cannot carry two data-bs-toggle. For a Bootstrap tooltip on a trigger, wrap the button in a Tooltip.

pill rounds the corners fully, square removes the radius:

loading replaces the label with a spinner. disabled sets the disabled attribute on a <button>; on a link it adds the disabled class, aria-disabled="true" and tabindex="-1".

With href, the button renders an <a> and type is ignored. Without it, type sets the button type, button by default:

tag picks the element: button, a, label or span. Left null (the default), it is an <a> with href and a <button> without; an explicit tag wins over href. A label or a span gets no type, href nor role, and disabled sets the disabled class and aria-disabled="true" on it.

A label is the styled trigger of a file input: clicking it opens the file picker, which a <button> cannot do. Put the input inside, hidden with visually-hidden so it stays focusable. The disabled class only blocks the pointer: disable the input too.

floating pins the button to the bottom corner of the viewport (btn-floating), for the main action of a page:

Confetti needs no component: tabler.js binds it to any element with data-bs-toggle="confetti", and attributes are forwarded to the button:

Prop Type Default Description
variant string 'primary' default (neutral) primary secondary success danger warning info dark light
appearance string 'filled' filled outline ghost link (btn-link) action (btn-action); link and action ignore variant
size string 'md' sm md lg xl
href string? null Renders <a href role="button"> instead of <button>, unless tag names another element
tag string? null button a label span; null for <a> with href, else <button>
type string 'button' button submit reset, only on a <button>
pill bool false Fully rounded corners (btn-pill)
square bool false No border radius (btn-square)
iconOnly bool false Icon-only button (btn-icon)
loading bool false Spinner instead of the label (btn-loading)
block bool false Full width (w-100)
disabled bool false disabled attribute on <button>; disabled class and aria-disabled on the others, tabindex on <a>
floating bool false Pinned to the bottom corner of the viewport (btn-floating)
animateIcon string? null Animates the icon on hover: pulse rotate shake tada move-start (btn-animate-icon-*)
icon string? null Leading icon name, rendered with Icon (icon)
iconEnd string? null Trailing icon name, rendered with Icon (icon icon-end)
modal string? null Id of the modal to open (data-bs-toggle="modal", data-bs-target, aria-controls)
offcanvas string? null Id of the offcanvas to open (data-bs-toggle="offcanvas", data-bs-target, aria-controls)
collapse string? null Id of the element to toggle (data-bs-toggle="collapse", data-bs-target, aria-controls, aria-expanded)
tooltip string? null Tooltip text (title, data-bs-toggle="tooltip" unless a trigger is set); aria-label of an iconOnly one

Other attributes go to the root element, and win over the generated role, data-bs-*, aria-* and title. The children are the label.

Block Default
icon A Tabler:Icon named icon with the icon class, when set
content Empty: the children, the label
iconEnd A Tabler:Icon named iconEnd with the icon icon-end classes, when set