Components
BaseButton
The button of the whole template. It wraps v-btn with the brand's button types, so every button looks the same.
components/ui/BaseButton.vue
View in the demo
Types
button-type picks the role of the button. Use one primary per view for the main action.
Type | Use it for |
|---|---|
primary | The main action of the view: Save, Create, Send. |
secondary | An important action next to the primary one. |
tertiary | Text in the primary colour for lighter actions that still invite a click: View all, Clear filters, Continue shopping. |
default | Neutral actions on the surface colour with a light grey border, like the text fields: Cancel, Export, Filters. |
inverse | Dark submit buttons in the auth pages. |
danger | Destructive actions such as Delete. |
ghost | Neutral text for actions that should step back: Cancel next to the main button, month arrows, closing a panel. It takes the colour of the surrounding text. |
on-color | The main action on a coloured surface: solid in the text colour of the surface (on-primary) with the surface colour as text. Set surface when the background is not primary. |
overlay | Secondary actions on a coloured surface: the text colour of the surface with a translucent veil and a thin outline of that colour. |
With icons
Sizes
Loading and disabled
Press Save to see the loading state. While loading is true the button ignores clicks.
On a coloured background
Put one on-color button for the main action and overlay for the rest, the same hierarchy as primary and default on the page. Both read the colour of the surface, so they invert in dark mode instead of disappearing.
Links and full width
A BaseButton with to renders a NuxtLink; with href it renders an anchor. block makes it fill its container.
API
It also accepts every prop, slot and event of v-btn, which it passes through.
Props
Name | Type | Default | Description |
|---|---|---|---|
button-type | any | "default" | The role of the button: primary, secondary, tertiary, default, inverse, danger, ghost, overlay or on-color. Sets the Vuetify variant, color and text colour, adapted to dark mode. |
surface | string | "primary" | The theme colour of the surface behind an on-color button. Defaults to primary. |
Accessibility
- A button with text needs nothing else. An icon-only button must be a
BaseIconButtonwitharia-label. - Use
type="submit"for the main button of a form so Enter submits it. - Prefer
toover@click="navigateTo()"for navigation: it renders a real link that can be opened in a new tab.