Button
Renders a <button type="button">, an <a role="button"> when href is set, or the element named by
tag.
<div class="btn-list"> <twig:Tabler:Button variant="default">Cancel</twig:Tabler:Button> <twig:Tabler:Button variant="primary">Save changes</twig:Tabler:Button></div><div class="btn-list"> <button type="button" class="btn">Cancel</button> <button type="button" class="btn btn-primary">Save changes</button></div>Variants
Section titled “Variants”variant sets the color. default is Tabler’s neutral button, a plain .btn:
<div class="btn-list"> {% for variant in ['default', 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'] %} <twig:Tabler:Button variant="{{ variant }}">{{ variant|capitalize }}</twig:Tabler:Button> {% endfor %}</div><div class="btn-list"> <button type="button" class="btn">Default</button> <button type="button" class="btn btn-primary">Primary</button> <button type="button" class="btn btn-secondary">Secondary</button> <button type="button" class="btn btn-success">Success</button> <button type="button" class="btn btn-danger">Danger</button> <button type="button" class="btn btn-warning">Warning</button> <button type="button" class="btn btn-info">Info</button> <button type="button" class="btn btn-dark">Dark</button> <button type="button" class="btn btn-light">Light</button></div>Appearances
Section titled “Appearances”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:
{% for appearance in ['filled', 'outline', 'ghost'] %} <div class="btn-list mb-2"> {% for variant in ['default', 'primary', 'success', 'danger'] %} <twig:Tabler:Button variant="{{ variant }}" appearance="{{ appearance }}">{{ appearance|capitalize }}</twig:Tabler:Button> {% endfor %} </div>{% endfor %}<div class="btn-list"> <twig:Tabler:Button appearance="link">Link</twig:Tabler:Button></div><div class="btn-list mb-2"> <button type="button" class="btn">Filled</button> <button type="button" class="btn btn-primary">Filled</button> <button type="button" class="btn btn-success">Filled</button> <button type="button" class="btn btn-danger">Filled</button></div><div class="btn-list mb-2"> <button type="button" class="btn btn-outline">Outline</button> <button type="button" class="btn btn-outline-primary">Outline</button> <button type="button" class="btn btn-outline-success">Outline</button> <button type="button" class="btn btn-outline-danger">Outline</button></div><div class="btn-list mb-2"> <button type="button" class="btn btn-ghost">Ghost</button> <button type="button" class="btn btn-ghost-primary">Ghost</button> <button type="button" class="btn btn-ghost-success">Ghost</button> <button type="button" class="btn btn-ghost-danger">Ghost</button></div><div class="btn-list"> <button type="button" class="btn btn-link">Link</button></div>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:
<twig:Tabler:ButtonActions> <twig:Tabler:Button appearance="action" aria-label="Edit"><twig:Tabler:Icon name="edit" /></twig:Tabler:Button> <twig:Tabler:Button appearance="action" aria-label="Share"><twig:Tabler:Icon name="share" /></twig:Tabler:Button> <twig:Tabler:Button appearance="action" aria-label="Delete"><twig:Tabler:Icon name="trash" /></twig:Tabler:Button></twig:Tabler:ButtonActions><div class="btn-actions"> <button type="button" class="btn btn-action" aria-label="Edit"><i class="ti ti-edit"></i></button> <button type="button" class="btn btn-action" aria-label="Share"><i class="ti ti-share"></i></button> <button type="button" class="btn btn-action" aria-label="Delete"><i class="ti ti-trash"></i></button></div><div class="btn-list"> <twig:Tabler:Button size="sm">Small</twig:Tabler:Button> <twig:Tabler:Button size="md">Medium</twig:Tabler:Button> <twig:Tabler:Button size="lg">Large</twig:Tabler:Button> <twig:Tabler:Button size="xl">Extra large</twig:Tabler:Button></div><div class="btn-list"> <button type="button" class="btn btn-sm btn-primary">Small</button> <button type="button" class="btn btn-primary">Medium</button> <button type="button" class="btn btn-lg btn-primary">Large</button> <button type="button" class="btn btn-xl btn-primary">Extra large</button></div>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):
<div class="btn-list"> <twig:Tabler:Button icon="plus">New user</twig:Tabler:Button> <twig:Tabler:Button variant="default" iconEnd="arrow-right">Next step</twig:Tabler:Button> <twig:Tabler:Button variant="default" appearance="outline" icon="download" animateIcon="move-start">Export</twig:Tabler:Button> <twig:Tabler:Button variant="success" icon="lucide:circle-check">Approve</twig:Tabler:Button> <twig:Tabler:Button variant="danger" icon="trash" iconOnly="{{ true }}" aria-label="Delete" /></div><div class="btn-list"> <button type="button" class="btn btn-primary"> <i class="ti ti-plus icon" aria-hidden="true"></i> New user </button> <button type="button" class="btn"> Next step <i class="ti ti-arrow-right icon icon-end" aria-hidden="true"></i> </button> <button type="button" class="btn btn-animate-icon btn-animate-icon-move-start btn-outline"> <i class="ti ti-download icon" aria-hidden="true"></i> Export </button> <button type="button" class="btn btn-success"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon" aria-hidden="true"> <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"> <circle cx="12" cy="12" r="10"></circle> <path d="m9 12l2 2l4-4"></path> </g> </svg> Approve </button> <button type="button" class="btn btn-icon btn-danger" aria-label="Delete"> <i class="ti ti-trash icon" aria-hidden="true"></i> </button></div>The icon and iconEnd blocks replace the generated icons. You can also put the icon in the children yourself, with
the icon class:
<div class="btn-list"> <twig:Tabler:Button variant="primary"> <twig:Tabler:Icon name="plus" class="icon" /> New user </twig:Tabler:Button> <twig:Tabler:Button variant="default" appearance="outline"> <twig:Tabler:Icon name="download" class="icon" /> Export </twig:Tabler:Button> <twig:Tabler:Button variant="danger" iconOnly="{{ true }}" aria-label="Delete"> <twig:Tabler:Icon name="trash" class="icon" /> </twig:Tabler:Button> <twig:Tabler:Button variant="default" appearance="ghost" iconOnly="{{ true }}" aria-label="Settings"> <twig:Tabler:Icon name="settings" class="icon" /> </twig:Tabler:Button></div><div class="btn-list"> <button type="button" class="btn btn-primary"> <i class="ti ti-plus icon"></i> New user </button> <button type="button" class="btn btn-outline"> <i class="ti ti-download icon"></i> Export </button> <button type="button" class="btn btn-icon btn-danger" aria-label="Delete"><i class="ti ti-trash icon"></i></button> <button type="button" class="btn btn-icon btn-ghost" aria-label="Settings"> <i class="ti ti-settings icon"></i> </button></div>animateIcon animates the icon when the button is hovered:
<div class="btn-list"> <twig:Tabler:Button variant="default" animateIcon="pulse"><twig:Tabler:Icon name="heart" class="icon" /> Pulse</twig:Tabler:Button> <twig:Tabler:Button variant="default" animateIcon="rotate"><twig:Tabler:Icon name="refresh" class="icon" /> Rotate</twig:Tabler:Button> <twig:Tabler:Button variant="default" animateIcon="shake"><twig:Tabler:Icon name="bell" class="icon" /> Shake</twig:Tabler:Button> <twig:Tabler:Button variant="default" animateIcon="tada"><twig:Tabler:Icon name="star" class="icon" /> Tada</twig:Tabler:Button> <twig:Tabler:Button variant="default" animateIcon="move-start"><twig:Tabler:Icon name="arrow-left" class="icon" /> Move start</twig:Tabler:Button></div><div class="btn-list"> <button type="button" class="btn btn-animate-icon btn-animate-icon-pulse"> <i class="ti ti-heart icon"></i> Pulse </button> <button type="button" class="btn btn-animate-icon btn-animate-icon-rotate"> <i class="ti ti-refresh icon"></i> Rotate </button> <button type="button" class="btn btn-animate-icon btn-animate-icon-shake"> <i class="ti ti-bell icon"></i> Shake </button> <button type="button" class="btn btn-animate-icon btn-animate-icon-tada"> <i class="ti ti-star icon"></i> Tada </button> <button type="button" class="btn btn-animate-icon btn-animate-icon-move-start"> <i class="ti ti-arrow-left icon"></i> Move start </button></div>Triggers
Section titled “Triggers”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.
<div class="btn-list mb-3"> <twig:Tabler:Button variant="danger" icon="trash" modal="button-delete-user">Delete user</twig:Tabler:Button> <twig:Tabler:Button variant="default" icon="menu-2" offcanvas="button-menu">Menu</twig:Tabler:Button> <twig:Tabler:Button variant="default" appearance="outline" icon="filter" collapse="button-filters">Filters</twig:Tabler:Button></div><div class="collapse" id="button-filters"> <div class="card card-body">Status, owner and creation date filters.</div></div>
<twig:Tabler:Modal id="button-delete-user" title="Delete Jane Doe?" text="She loses access to the workspace immediately." /><twig:Tabler:Offcanvas id="button-menu" title="Menu" text="Dashboard, projects and settings." /><div class="btn-list mb-3"> <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#button-delete-user" aria-controls="button-delete-user" > <i class="ti ti-trash icon" aria-hidden="true"></i> Delete user </button> <button type="button" class="btn" data-bs-toggle="offcanvas" data-bs-target="#button-menu" aria-controls="button-menu" > <i class="ti ti-menu-2 icon" aria-hidden="true"></i> Menu </button> <button type="button" class="btn btn-outline" data-bs-toggle="collapse" data-bs-target="#button-filters" aria-controls="button-filters" aria-expanded="false" > <i class="ti ti-filter icon" aria-hidden="true"></i> Filters </button></div><div class="collapse" id="button-filters"> <div class="card card-body">Status, owner and creation date filters.</div></div><div class="modal" tabindex="-1" id="button-delete-user"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Delete Jane Doe?</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body">She loses access to the workspace immediately.</div> </div> </div></div><div class="offcanvas offcanvas-start" tabindex="-1" id="button-menu"> <div class="offcanvas-header"> <h5 class="offcanvas-title">Menu</h5> <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button> </div> <div class="offcanvas-body">Dashboard, projects and settings.</div></div>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
Section titled “Tooltip”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:
<div class="btn-list"> <twig:Tabler:Button variant="default" tooltip="Saves a draft, visible only to you">Save draft</twig:Tabler:Button> <twig:Tabler:Button variant="default" appearance="ghost" icon="settings" iconOnly="{{ true }}" tooltip="Settings" /> <twig:Tabler:Button variant="default" appearance="ghost" icon="bell" iconOnly="{{ true }}" tooltip="Notifications" aria-label="Notifications, 3 unread" /></div><div class="btn-list"> <button type="button" class="btn" data-bs-toggle="tooltip" title="Saves a draft, visible only to you"> Save draft </button> <button type="button" class="btn btn-icon btn-ghost" data-bs-toggle="tooltip" title="Settings" aria-label="Settings" > <i class="ti ti-settings icon" aria-hidden="true"></i> </button> <button type="button" class="btn btn-icon btn-ghost" data-bs-toggle="tooltip" title="Notifications" aria-label="Notifications, 3 unread" > <i class="ti ti-bell icon" aria-hidden="true"></i> </button></div>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.
Shapes
Section titled “Shapes”pill rounds the corners fully, square removes the radius:
<div class="btn-list"> <twig:Tabler:Button variant="primary" pill="{{ true }}">Pill</twig:Tabler:Button> <twig:Tabler:Button variant="primary" square="{{ true }}">Square</twig:Tabler:Button> <twig:Tabler:Button variant="primary" pill="{{ true }}" iconOnly="{{ true }}" aria-label="Like"> <twig:Tabler:Icon name="heart" class="icon" /> </twig:Tabler:Button></div><div class="btn-list"> <button type="button" class="btn btn-pill btn-primary">Pill</button> <button type="button" class="btn btn-square btn-primary">Square</button> <button type="button" class="btn btn-pill btn-icon btn-primary" aria-label="Like"> <i class="ti ti-heart icon"></i> </button></div>States
Section titled “States”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".
<div class="btn-list"> <twig:Tabler:Button variant="primary" loading="{{ true }}">Deploying</twig:Tabler:Button> <twig:Tabler:Button variant="primary" disabled="{{ true }}">Disabled button</twig:Tabler:Button> <twig:Tabler:Button href="/invoices" variant="secondary" disabled="{{ true }}">Disabled link</twig:Tabler:Button></div><div class="btn-list"> <button type="button" class="btn btn-loading btn-primary">Deploying</button> <button type="button" class="btn btn-primary" disabled>Disabled button</button> <a href="/invoices" class="btn disabled btn-secondary" role="button" aria-disabled="true" tabindex="-1"> Disabled link </a></div>Links and form buttons
Section titled “Links and form buttons”With href, the button renders an <a> and type is ignored. Without it, type sets the button type, button by
default:
<div class="btn-list"> <twig:Tabler:Button href="/users/42" variant="secondary" appearance="ghost">View profile</twig:Tabler:Button> <twig:Tabler:Button type="submit" variant="primary">Create invoice</twig:Tabler:Button></div><div class="btn-list"> <a href="/users/42" class="btn btn-ghost-secondary" role="button">View profile</a> <button type="submit" class="btn btn-primary">Create invoice</button></div>Other elements
Section titled “Other elements”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.
<div class="btn-list"> <twig:Tabler:Button tag="label" icon="upload"> <input type="file" name="import" accept=".csv" class="visually-hidden"> Import a CSV file </twig:Tabler:Button> <twig:Tabler:Button tag="label" variant="default" appearance="outline" disabled="{{ true }}"> <input type="file" name="attachment" class="visually-hidden" disabled> Attach a file </twig:Tabler:Button></div><div class="btn-list"> <label class="btn btn-primary"> <i class="ti ti-upload icon" aria-hidden="true"></i> <input type="file" name="import" accept=".csv" class="visually-hidden" /> Import a CSV file </label> <label class="btn disabled btn-outline" aria-disabled="true"> <input type="file" name="attachment" class="visually-hidden" disabled /> Attach a file </label></div>Full width
Section titled “Full width”<twig:Tabler:Button variant="primary" block="{{ true }}">Sign in</twig:Tabler:Button><button type="button" class="btn w-100 btn-primary">Sign in</button>Floating
Section titled “Floating”floating pins the button to the bottom corner of the viewport (btn-floating), for the main action of a page:
<twig:Tabler:Button variant="primary" floating="{{ true }}" iconOnly="{{ true }}" aria-label="New ticket"> <twig:Tabler:Icon name="plus" class="icon" /></twig:Tabler:Button><button type="button" class="btn btn-icon btn-floating btn-primary" aria-label="New ticket"> <i class="ti ti-plus icon"></i></button>Confetti
Section titled “Confetti”Confetti needs no component: tabler.js binds it to any element with data-bs-toggle="confetti", and attributes are
forwarded to the button:
<twig:Tabler:Button variant="success" data-bs-toggle="confetti" data-bs-count="150">Celebrate</twig:Tabler:Button><button type="button" class="btn btn-success" data-bs-toggle="confetti" data-bs-count="150">Celebrate</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.
Blocks
Section titled “Blocks”| 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 |
