Keyboard shortcut: Ctrl + K
Get started

Button

VButton triggers an action or navigates to a URL when href is set.

Usage

vue
<script setup lang="ts">
import { VButton } from 'vectis-ui'
</script>

<template>
  <VButton>Save changes</VButton>
</template>

Examples

Variants and tones

Use variant for the visual style and tone for the action’s intent.

vue
<script setup lang="ts">
import { VButton } from 'vectis-ui'

const variants = ['solid', 'soft', 'outline', 'ghost'] as const
const tones = ['accent', 'neutral', 'danger'] as const
</script>

<template>
  <div v-for="tone in tones" :key="tone" class="row">
    <VButton v-for="variant in variants" :key="variant" :variant="variant" :tone="tone">
      {{ variant }}
    </VButton>
  </div>
</template>

<style scoped>
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vectis-space-3);
}
</style>

Elevated

elevated adds a shadow. The ghost and outline variants also gain a background.

vue
<script setup lang="ts">
import { VButton } from 'vectis-ui'

const variants = ['solid', 'soft', 'outline', 'ghost'] as const
</script>

<template>
  <div class="row">
    <VButton v-for="variant in variants" :key="variant" :variant="variant">
      {{ variant }}
    </VButton>
  </div>

  <div class="row">
    <VButton v-for="variant in variants" :key="variant" :variant="variant" elevated>
      {{ variant }}
    </VButton>
  </div>
</template>

<style scoped>
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vectis-space-3);
}
</style>

Sizes

size adjusts the height, padding, text and icons.

vue
<script setup lang="ts">
import { VButton } from 'vectis-ui'
</script>

<template>
  <VButton size="xs">Extra small</VButton>
  <VButton size="sm">Small</VButton>
  <VButton size="md">Medium</VButton>
  <VButton size="lg">Large</VButton>
  <VButton size="xl">Extra large</VButton>
</template>

Full width

fullWidth makes the button fill its parent’s width.

vue
<script setup lang="ts">
import { VButton } from 'vectis-ui'
</script>

<template>
  <div class="column">
    <VButton>Save</VButton>
    <VButton variant="outline" tone="neutral">Cancel</VButton>
  </div>

  <div class="column">
    <VButton full-width>Save</VButton>
    <VButton full-width variant="outline" tone="neutral">Cancel</VButton>
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: var(--vectis-space-3);
  inline-size: 220px;
}
</style>

With icons

Set iconStart or iconEnd to add icons. Use #start or #end for custom content.

vue
<script setup lang="ts">
import { VButton } from 'vectis-ui'
import { arrow_right_alt as arrowRightAlt, notifications, search } from 'vectis-ui/icons'
</script>

<template>
  <VButton :icon-start="search">Search</VButton>
  <VButton :icon-end="arrowRightAlt">Next</VButton>
  <VButton :icon-start="search" :icon-end="arrowRightAlt">Search and go</VButton>
  <VButton :icon-start="notifications" variant="outline" tone="neutral">Notify me</VButton>
  <VButton :icon-start="notifications" icon-filled variant="outline" tone="neutral">
    Notifying
  </VButton>
</template>

Custom icons

Both icon props accept an IconSource: a built-in icon, a name resolved by your application, SVG path data, a component or an image.

vue
<script setup lang="ts">
import { h } from 'vue'
import { VButton } from 'vectis-ui'
import { ICON_VIEW_BOX, cloud_upload as cloudUpload, code, search } from 'vectis-ui/icons'

import firefoxLogo from '~/assets/img/firefox-browser-svg.svg'

// Component icon sources require a single SVG root.
const CodeIcon = () =>
  h('svg', { viewBox: ICON_VIEW_BOX, fill: 'currentColor' }, [h('path', { d: code.paths[0] })])
</script>

<template>
  <VButton :icon-start="search">A library icon</VButton>
  <VButton icon-start="translate" variant="outline" tone="neutral">A name</VButton>
  <VButton :icon-start="{ path: cloudUpload.paths[0] }" variant="outline" tone="neutral">
    SVG path data
  </VButton>
  <VButton :icon-start="{ component: CodeIcon }" variant="outline" tone="neutral">
    A component
  </VButton>
  <VButton :icon-start="{ src: firefoxLogo }" variant="outline" tone="neutral">An image</VButton>
</template>

href renders a link. Navigation is blocked while the button is disabled or loading.

vue
<script setup lang="ts">
import { VButton } from 'vectis-ui'
import { arrow_right_alt as arrowRightAlt } from 'vectis-ui/icons'
</script>

<template>
  <VButton href="#usage" :icon-end="arrowRightAlt">Back to usage</VButton>
  <VButton href="#usage" variant="outline" tone="neutral" disabled>Unavailable</VButton>
</template>

States

disabled prevents activation. loading also shows a spinner and sets aria-busy.

vue
<script setup lang="ts">
import { VButton } from 'vectis-ui'

const variants = ['solid', 'soft', 'outline', 'ghost'] as const
</script>

<template>
  <div class="row">
    <VButton v-for="variant in variants" :key="variant" :variant="variant" disabled>
      {{ variant }}
    </VButton>
  </div>

  <div class="row">
    <VButton loading>Saving</VButton>
    <VButton variant="outline" tone="neutral" loading>Checking</VButton>
  </div>
</template>

<style scoped>
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vectis-space-3);
}
</style>

Router

VButton renders a real <a> when href is set. With Nuxt or Vue Router, render it inside the router link in custom mode and pass on href and navigate. A click with a modifier key still opens a new tab.

vue
<RouterLink v-slot="{ href, navigate }" to="/settings" custom>
  <VButton :href="href" @click="navigate">Settings</VButton>
</RouterLink>

API

Props

PropTypeDefault
variantButtonVariant'solid' | 'outline' | 'ghost' | 'soft''solid'
Visual style: solid for a filled background, soft for a tinted background, outline for a border, or ghost for a transparent background until hover. VButtonGroup overrides this value.
toneButtonTone'accent' | 'neutral' | 'danger''accent'
Action intent: accent for a primary action, neutral for a secondary action, or danger for a destructive action. Inherits from VButtonGroup when omitted; otherwise defaults to accent.
elevatedbooleanfalse
Adds a shadow and, for ghost and outline, a background. VButtonGroup overrides this value.
sizeButtonSize'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
Button size. VButtonGroup overrides this value.
fullWidthbooleanfalse
Fills the parent’s width.
hrefstringnone
Link destination. Renders an <a> instead of a <button>. When disabled or loading, the link loses its destination and cannot receive focus or navigate.
typeButtonHTMLAttributes['type']'button'
Native button type. Ignored when href is set.
disabledbooleanfalse
Prevents activation and removes the button from the tab order.
loadingbooleanfalse
Disables the button, sets aria-busy and replaces iconStart or #start content with a spinner.
iconStartIconSourcenone
Icon before the label. Replaced by the #start slot.
iconEndIconSourcenone
Icon after the label. Replaced by the #end slot.
iconFilledbooleanfalse
Requests filled versions of iconStart and iconEnd, where supported. Does not affect slot content.

Slots

SlotType
default{}
Button label.
start{}
Content before the label, replacing iconStart. Hidden while loading. Add aria-hidden="true" to decorative content.
end{}
Content after the label, replacing iconEnd.

Types

Types used in the API tables. Import exported types from vectis-ui.

export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender