Skip to content
Oruga
Bulma
Bootstrap
Tailwind

Button ​

The Button component extends the HTML's native button element with more features. For example, the button can be have different colors, sizes, and states.

The component implements the W3C ARIA APG Button Pattern.

Examples ​

Base ​

The label property is used to populate the text of the button. Alternatively, you can naturaly use the default slot instead.

html
<section>
    <o-field grouped>
        <o-field label="Size">
            <o-select v-model="settings.size">
                <option value="small">small</option>
                <option value="default">default</option>
                <option value="medium">medium</option>
                <option value="large">large</option>
            </o-select>
        </o-field>
        <o-field label="Variant">
            <o-select v-model="settings.variant">
                <option value="default">default</option>
                <option value="primary">primary</option>
                <option value="secondary">secondary</option>
                <option value="success">success</option>
                <option value="info">info</option>
                <option value="warning">warning</option>
                <option value="danger">danger</option>
            </o-select>
        </o-field>
        <o-field label="Inverted">
            <o-switch v-model="settings.inverted" />
        </o-field>
        <o-field label="Outlined">
            <o-switch v-model="settings.outlined" />
        </o-field>
        <o-field label="Rounded">
            <o-switch v-model="settings.rounded" />
        </o-field>
        <o-field label="Disabled">
            <o-switch v-model="settings.disabled" />
        </o-field>
        <o-field label="Loading">
            <o-switch v-model="settings.loading" />
        </o-field>
    </o-field>

    <o-button
        :variant="settings.variant"
        :size="settings.size"
        :rounded="settings.rounded"
        :inverted="settings.inverted"
        :outlined="settings.outlined"
        :disabled="settings.disabled"
        :loading="settings.loading"
        @click="clickMe">
        Click Me
    </o-button>
</section>
javascript
import { reactive } from "vue";

const clickMe = (): void => {
    alert("Clicked!");
};

const settings = reactive({
    variant: "primary",
    size: "medium",
    rounded: false,
    outlined: false,
    inverted: false,
    disabled: false,
    loading: false,
});

States ​

You can disable the button by using the the disabled property.
You can use the rounded property to curve the edges.

html
<section class="odocs-spaced">
    <p>
        <o-button label="Normal" />
        <o-button label="Disabled" disabled />
        <o-button label="Rounded" rounded />
    </p>
    <p>
        <o-button label="Expanded" expanded />
    </p>
</section>

Variants ​

Different styles can be achieved with the variant prop.

html
<section class="odocs-spaced">
    <p>
        <o-button label="Default" />
        <o-button label="Primary" variant="primary" />
        <o-button label="Secondary" variant="secondary" />
        <o-button label="Success" variant="success" />
        <o-button label="Info" variant="info" />
        <o-button label="Warning" variant="warning" />
        <o-button label="Danger" variant="danger" />
    </p>
</section>

Outlined ​

Use the outlined prop in combination with the variant prop for a lightweight look.

html
<section class="odocs-spaced">
    <p>
        <o-button label="Default" outlined />
        <o-button label="Primary" variant="primary" outlined />
        <o-button label="Secondary" variant="secondary" outlined />
        <o-button label="Success" variant="success" outlined />
        <o-button label="Info" variant="info" outlined />
        <o-button label="Warning" variant="warning" outlined />
        <o-button label="Danger" variant="danger" outlined />
    </p>
</section>

Inverted ​

Use the inverted prop in combination with the variant prop for a clickable label look.

html
<section class="odocs-spaced">
    <p>
        <o-button label="Default" inverted />
        <o-button label="Primary" variant="primary" inverted />
        <o-button label="Secondary" variant="secondary" inverted />
        <o-button label="Success" variant="success" inverted />
        <o-button label="Info" variant="info" inverted />
        <o-button label="Warning" variant="warning" inverted />
        <o-button label="Danger" variant="danger" inverted />
    </p>
</section>

Sizes ​

The component can be displayed in different sizes using the size prop.

html
<section class="odocs-spaced">
    <p>
        <o-button label="Small" size="small" />
        <o-button label="Default" />
        <o-button label="Medium" size="medium" />
        <o-button label="Large" size="large" />
    </p>
</section>

Icons ​

Add an icon to the button to explain its function more visually.

html
<section class="odocs-spaced">
    <p>
        <o-button label="Add" size="small" icon-left="plus" />
        <o-button label="Add" icon-left="plus" />
        <o-button label="Add" size="medium" icon-left="plus" />
        <o-button label="Add" size="large" icon-left="plus" />
    </p>

    <p>
        <o-button label="Delete" variant="danger" icon-left="trash" />
        <o-button label="Delete" variant="danger" icon-right="trash" />
        <o-button variant="danger" aria-label="Delete" icon-right="trash" />
    </p>
</section>

Tags ​

Instead of using the HTML button tag, the HTML tag can be customised using the tag prop, for example to define links using vue-router and router-link tag.

html
<section class="odocs-spaced">
    <p>
        <o-button label="Button" />

        <o-button
            tag="a"
            href="https://oruga-ui.com"
            target="_blank"
            label="Anchor" />

        <o-button tag="input" type="submit" value="Submit input" />

        <!-- Need vue-router -->
        <o-button tag="router-link" to="/home" label="Docs" />
    </p>
</section>

Button Component ​

The classic button, in different colors, sizes, and states.

html
<o-button></o-button>

Props ​

Prop nameDescriptionTypeValuesDefault
aria-activedescendantIdentifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.string-
aria-atomicIndicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.Booleanish-
aria-autocompleteIndicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
presented if they are made.
"both" | "inline" | "list" | "none"-
aria-busyIndicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user.Booleanish-
aria-checkedIndicates the current "checked" state of checkboxes, radio buttons, and other widgets."mixed" | Booleanish-
aria-colcountDefines the total number of columns in a table, grid, or treegrid.Numberish-
aria-colindexDefines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.Numberish-
aria-colspanDefines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.Numberish-
aria-controlsIdentifies the element (or elements) whose contents or presence are controlled by the current element.string-
aria-currentIndicates the element that represents the current item within a container or set of related elements."date" | "location" | "page" | "step" | "time" | Booleanish-
aria-describedbyIdentifies the element (or elements) that describes the object.string-
aria-detailsIdentifies the element that provides a detailed, extended description for the object.string-
aria-disabledIndicates that the element is perceivable but disabled, so it is not editable or otherwise operable.Booleanish-
aria-dropeffect
deprecated - in ARIA 1.1
Indicates what functions can be performed when a dragged object is released on the drop target.
"copy" | "execute" | "link" | "move" | "none" | "popup"-
aria-errormessageIdentifies the element that provides an error message for the object.string-
aria-expandedIndicates whether the element, or another grouping element it controls, is currently expanded or collapsed.Booleanish-
aria-flowtoIdentifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
allows assistive technology to override the general default of reading in document source order.
string-
aria-grabbed
deprecated - in ARIA 1.1
Indicates an element's "grabbed" state in a drag-and-drop operation.
Booleanish-
aria-haspopupIndicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element."dialog" | "grid" | "listbox" | "menu" | "tree" | Booleanish-
aria-hiddenIndicates whether the element is exposed to an accessibility API.Booleanish-
aria-invalidIndicates the entered value does not conform to the format expected by the application."grammar" | "spelling" | Booleanish-
aria-keyshortcutsIndicates keyboard shortcuts that an author has implemented to activate or give focus to an element.string-
aria-labelDefines a string value that labels the current element.string-
aria-labelledbyIdentifies the element (or elements) that labels the current element.string-
aria-levelDefines the hierarchical level of an element within a structure.Numberish-
aria-liveIndicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region."assertive" | "off" | "polite"-
aria-modalIndicates whether an element is modal when displayed.Booleanish-
aria-multilineIndicates whether a text box accepts multiple lines of input or only a single line.Booleanish-
aria-multiselectableIndicates that the user may select more than one item from the current selectable descendants.Booleanish-
aria-orientationIndicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous."horizontal" | "vertical"-
aria-ownsIdentifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
string-
aria-placeholderDefines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
A hint could be a sample value or a brief description of the expected format.
string-
aria-posinsetDefines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.Numberish-
aria-pressedIndicates the current "pressed" state of toggle buttons."mixed" | Booleanish-
aria-readonlyIndicates that the element is not editable, but is otherwise operable.Booleanish-
aria-relevantIndicates what notifications the user agent will trigger when the accessibility tree within a live region is modified."additions removals" | "additions text" | "additions" | "all" | "removals additions" | "removals text" | "removals" | "text additions" | "text removals" | "text"-
aria-requiredIndicates that user input is required on the element before a form may be submitted.Booleanish-
aria-roledescriptionDefines a human-readable, author-localized description for the role of an element.string-
aria-rowcountDefines the total number of rows in a table, grid, or treegrid.Numberish-
aria-rowindexDefines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.Numberish-
aria-rowspanDefines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.Numberish-
aria-selectedIndicates the current "selected" state of various widgets.Booleanish-
aria-setsizeDefines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.Numberish-
aria-sortIndicates if items in a table or grid are sorted in ascending or descending order."ascending" | "descending" | "none" | "other"-
aria-valuemaxDefines the maximum allowed value for a range widget.Numberish-
aria-valueminDefines the minimum allowed value for a range widget.Numberish-
aria-valuenowDefines the current value for a range widget.Numberish-
aria-valuetextDefines the human readable text alternative of aria-valuenow for a range widget.string-
disabledInteraction will be disabledboolean-false
expandedButton will be expanded (full-width)boolean-false
formSame as native formstring-
formactionOverride the parent form's action URL (submit buttons only)string-
formenctypeOverride the parent form's enctype (submit buttons only)string-
formmethodOverride the parent form's method (submit buttons only)string-
formnovalidateSkip HTML5 validation for this submit buttonBooleanish-
formtargetOverride the parent form's target (submit buttons only)string-
iconLeftIcon name to show on the leftstring-
iconPackIcon pack to usestringmdi, fa, fas and any other custom icon pack
From config:
button: {
  iconPack: undefined
}
iconRightIcon name to show on the rightstring-
invertedEnable inverted styleboolean-false
labelButton label, unnecessary when default slot is usedstring-
loadingEnable loading styleboolean-false
nameSame as native namestring-
outlinedEnable outlined styleboolean-false
overrideOverride existing theme classes completelyboolean-
roundedEnable rounded styleboolean-
From config:
button: {
  rounded: false
}
sizeSize of the controlstringsmall, medium, large
From config:
button: {
  size: undefined
}
tagButton tag nameDynamicComponentbutton, a, input, router-link, nuxt-link (or other nuxt alias)
From config:
button: {
  tag: "button"
}
typeButton type, like native"button" | "reset" | "submit"button, submit, reset"button"
valueSame as native valuenumber | readonly string[] | string-
variantColor variant of the controlstringprimary, info, success, warning, danger, and any other custom color
From config:
button: {
  variant: undefined
}

Events ​

Event namePropertiesDescription
clickevent Event - native eventbutton click event

Slots ​

NameDescriptionBindings
leftOverride the left icon
defaultOverride the label, default is label prop
rightOverride the right icon

Class Inspector ​

Classes applied to the element:
➜ Want to know how does the Class Inspector work?
Class propDescriptionPropsSuffixes
rootClass
Class of the root element.
sizeClass
Class of the root element with size.
sizesmall
medium
large
variantClass
Class of the root element with variant.
variantprimary
info
warning
danger
outlinedClass
Class of the root element when outlined.
outlinedprimary
info
warning
danger
invertedClass
Class of the root element when inverted.
invertedprimary
info
warning
danger
loadingClass
Class of the root element when loading.
loading
expandedClass
Class of the root element when expanded.
expanded
roundedClass
Class of the root element when rounded.
rounded
disabledClass
Class of the root element when disabled.
disabled
iconClass
Class of the icon element.
iconLeft
iconRight
iconLeftClass
Class of the icon element on the left.
iconLeft
iconRightClass
Class of the icon element on the right.
iconRight
labelClass
Class of the label element.

Sass Variables ​

Current theme ➜ Oruga

SASS VariableDefault
$button-spacerh.useVar("control-spacer")
$button-heighth.useVar("control-height")
$button-paddingh.useVar("control-padding-vertical") h.useVar("control-padding-horizontal")
$button-loading-animation-durationh.useVar("animation-speed-slow")
$button-disabled-opacityh.useVar("control-disabled-opacity")
$button-colorh.useVar("font-color")
$button-font-sizeh.useVar("font-size")
$button-font-weighth.useVar("font-weight")
$button-line-heighth.useVar("line-height")
$button-box-shadownone
$button-border-widthh.useVar("control-border-width")
$button-border-stylesolid
$button-border-colorh.useVar("control-border-color")
$button-border-radiush.useVar("border-radius")
$button-background-colorh.useVar("control-background-color")
$button-hover-color$button-color
$button-hover-background-color$button-background-color
$button-hover-border-colorh.useVar("grey-light")
$button-outlined-background-colortransparent
$button-outlined-border-colorh.useVar("grey-light")

See ➜ 📄 SCSS file

Current theme ➜ Bulma

The theme does not have any custom variables for this component.

Current theme ➜ Bootstrap

SASS VariableDefault
$btn-spacer0.5rem
$btn-height2.35em
$btn-border-colorvar(--#{$prefix}border-color)
$btn-hover-border-colorvar(--#{$prefix}border-color)
$btn-hover-box-shadow$box-shadow-sm

See ➜ 📄 SCSS file

Current theme ➜ Tailwind

SASS VariableDefault
// $btn-spacer0.5rem
// $btn-font-sizevar(--text-base)
// $btn-font-weight500
// $btn-padding0.70rem 0.70rem

See ➜ 📄 SCSS file

Released under the MIT License.