Button

Share via

Use the button shortcode to display a button with a hyperlink.

Overview

Use the button shortcode to display a button with a hyperlink. The inner content is used as button title. The button supports an optional badge and tooltip. As an example, the following shortcode displays a tooltip for a dark button with a badge.

markdown
{{< button color="dark" tooltip="Click on the inbox to view your unread messages" href="#!" badge="99+" >}}
    Inbox
{{< /button >}}

Arguments

The shortcode supports the following arguments:

ArgumentRequiredDescription
hrefNoOptional address for the button or hyperlink. Automatically assigned when using collapse.
relrefNoOptional name of the page to link to. Replaces href with a relative link if set.
stateNoOptional state of the button, either “enabled” (default), “disabled”, “active”, or “inactive”.
sizeNoOptional size of the button, either “sm”, “md” (default), or “lg”.
colorNoOptional theme color of the element, either “primary” (default), “secondary”, “success”, “danger”, “warning”, “info”, “light”, “dark”, “white” or “black”.
badgeNoOptional positioned badge to display on top of the button.
outlineNoOptional flag indicating the button should be outlined, either “false” (default) or “true”.
aria-labelNoOptional label for the badge.
tooltipNoOptional text to display in a tooltip. Cannot be used together with collapse. Ignored for active/inactive buttons.
toastNoOptional id of the toast message to display when the button is clicked.
collapseNoOptional panel to collapse. Cannot be used together with tooltip. Ignored for active/inactive buttons.
placementNoHow to position the tooltip: “top” (default), “bottom”, “left”, or “right”.

Example

Statefull buttons

Set the state argument to change the appearance and behavior of the button.

markdown
{{< button color="primary" href="#!" state="enabled" >}}Enabled{{< /button >}}
{{< button color="primary" href="#!" state="disabled" >}}Disabled{{< /button >}}
{{< button color="primary" href="#!" state="active" >}}Active{{< /button >}}
{{< button color="primary" href="#!" state="inactive" >}}Inactive{{< /button >}}

Sized buttons

Set the size argument to resize the button.

markdown
{{< button color="primary" href="#!" size="sm" >}}sm{{< /button >}}
{{< button color="primary" href="#!" size="md" >}}md{{< /button >}}
{{< button color="primary" href="#!" size="lg" >}}lg{{< /button >}}

Colored buttons

Set the color argument to define the background color with a matching title color.

markdown
{{< button color="primary" href="#!" size="sm" >}}primary{{< /button >}}
{{< button color="secondary" href="#!" size="sm" >}}secondary{{< /button >}}
{{< button color="success" href="#!" size="sm" >}}success{{< /button >}}
{{< button color="danger" href="#!" size="sm" >}}danger{{< /button >}}
{{< button color="warning" href="#!" size="sm" >}}warning{{< /button >}}
{{< button color="info" href="#!" size="sm" >}}info{{< /button >}}
{{< button color="light" href="#!" size="sm" >}}light{{< /button >}}
{{< button color="dark" href="#!" size="sm" >}}dark{{< /button >}}

Buttons with a badge

Set the badge argument to add a badge to the top right of the button.

markdown
{{< button color="secondary" href="#!" badge="99+" >}}
    Inbox
{{< /button >}}

Outlined buttons

Set the outline argument to true to adjust the style of the button.

markdown
{{< button color="primary" href="#!" size="sm" outline="true" >}}primary{{< /button >}}
{{< button color="secondary" href="#!" size="sm" outline="true" >}}secondary{{< /button >}}
{{< button color="success" href="#!" size="sm" outline="true" >}}success{{< /button >}}
{{< button color="danger" href="#!" size="sm" outline="true" >}}danger{{< /button >}}
{{< button color="warning" href="#!" size="sm" outline="true" >}}warning{{< /button >}}
{{< button color="info" href="#!" size="sm" outline="true" >}}info{{< /button >}}
{{< button color="light" href="#!" size="sm" outline="true" >}}light{{< /button >}}
{{< button color="dark" href="#!" size="sm" outline="true" >}}dark{{< /button >}}

Buttons with a tooltip

Set the tooltip argument in conjunction with placement to show a tooltip when hovering over the button.

markdown
{{< button color="dark" tooltip="Click on the inbox to view your unread messages" href="#!" placement="top" >}}
    Inbox
{{< /button >}}

{{< button color="dark" tooltip="Click on the inbox to view your unread messages" href="#!" placement="bottom" >}}
    Inbox
{{< /button >}}

{{< button color="dark" tooltip="Click on the inbox to view your unread messages" href="#!" placement="left" >}}
    Inbox
{{< /button >}}

{{< button color="dark" tooltip="Click on the inbox to view your unread messages" href="#!" placement="right" >}}
    Inbox
{{< /button >}}

Buttons with a collapsible panel

Reveal or hide a collapsible panel by linking the panel’s id to the button with the argument collapse.

Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
markdown
<div class="collapse pb-3" id="collapseExample">
    <div class="card card-body">
        Some placeholder content for the collapse component. This panel is hidden by default
        but revealed when the user activates the relevant trigger.
    </div>
</div>

<!-- markdownlint-disable MD037 -->
{{< button color="dark" collapse="collapseExample" >}}
    Collapse
{{< /button >}}