Keyboard shortcut: Ctrl + K
Get started

Icon button

VIconButton displays an icon for an action or link. Its required label provides the accessible name.

Usage

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

<template>
  <VIconButton label="Search" :icon="search" />
</template>

Examples

Variants and tones

Uses the same variants and tones as VButton, with ghost and neutral as defaults.

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

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">
    <VIconButton
      v-for="variant in variants"
      :key="variant"
      :icon="notifications"
      :variant="variant"
      :tone="tone"
      :label="`Notifications, ${variant} ${tone}`"
    />
  </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 { VIconButton } from 'vectis-ui'
import { notifications } from 'vectis-ui/icons'

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

<template>
  <div class="row">
    <VIconButton
      v-for="variant in variants"
      :key="variant"
      :icon="notifications"
      :variant="variant"
      :label="`Notifications, ${variant}`"
    />
  </div>

  <div class="row">
    <VIconButton
      v-for="variant in variants"
      :key="variant"
      :icon="notifications"
      :variant="variant"
      elevated
      :label="`Notifications, ${variant} raised`"
    />
  </div>
</template>

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

Sizes

size adjusts the button and icon.

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

const sizes = ['xs', 'sm', 'md', 'lg', 'xl'] as const
</script>

<template>
  <div class="row">
    <VIconButton
      v-for="size in sizes"
      :key="size"
      :icon="search"
      :size="size"
      variant="outline"
      :label="`Search, ${size}`"
    />
  </div>
</template>

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

Shapes

shape sets a square or circular shape. Joined buttons in VButtonGroup keep straight edges between segments.

vue
<script setup lang="ts">
import { VButtonGroup, VIconButton } from 'vectis-ui'
import {
  arrow_downward as arrowDownward,
  arrow_upward as arrowUpward,
  close,
  swap_vert as swapVert,
} from 'vectis-ui/icons'

const sizes = ['sm', 'md', 'lg'] as const
</script>

<template>
  <div class="stack">
    <div class="row">
      <VIconButton
        v-for="size in sizes"
        :key="size"
        :icon="close"
        :size="size"
        variant="outline"
        :label="`Close, ${size}`"
      />
      <VIconButton
        v-for="size in sizes"
        :key="`${size}-circular`"
        :icon="close"
        :size="size"
        shape="circular"
        variant="outline"
        :label="`Close, circular ${size}`"
      />
    </div>

    <VButtonGroup variant="outline">
      <VIconButton :icon="arrowUpward" shape="circular" label="Sort ascending" />
      <VIconButton :icon="swapVert" shape="circular" label="Unsorted" />
      <VIconButton :icon="arrowDownward" shape="circular" label="Sort descending" />
    </VButtonGroup>
  </div>
</template>

<style scoped>
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  align-items: start;
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--vectis-space-3);
}
</style>

Icons

Use icon or the default slot to supply an icon. iconFilled requests a filled version, where supported.

vue
<script setup lang="ts">
import { VIcon, VIconButton } from 'vectis-ui'
import { ICON_VIEW_BOX, code, notifications, search } from 'vectis-ui/icons'

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

<template>
  <VIconButton :icon="search" variant="outline" label="Search" />
  <VIconButton icon="translate" variant="outline" label="Translate" />
  <VIconButton :icon="{ path: code.paths[0] }" variant="outline" label="View the source" />
  <VIconButton :icon="{ src: firefoxLogo }" variant="outline" label="Open in Firefox" />

  <VIconButton :icon="notifications" icon-filled variant="outline" label="3 new notifications" />

  <!-- The button is already named; keep custom icon content decorative. -->
  <VIconButton variant="outline" label="Notifications, larger glyph">
    <VIcon :name="notifications" :size="28" />
  </VIconButton>
  <VIconButton variant="outline" label="Add">
    <svg :viewBox="ICON_VIEW_BOX" fill="none" stroke="currentColor" stroke-width="80">
      <path d="M480-800v640M160-480h640" stroke-linecap="round" />
    </svg>
  </VIconButton>
</template>

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

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

<template>
  <VIconButton href="#usage" :icon="arrowRightAlt" variant="outline" label="Back to usage" />

  <VIconButton
    href="https://github.com"
    target="_blank"
    rel="noreferrer"
    :icon="code"
    variant="outline"
    label="View the source, opens in a new tab"
  />

  <VIconButton href="#usage" :icon="arrowRightAlt" variant="outline" disabled label="Unavailable" />
</template>

States

disabled prevents activation. loading also replaces the icon with a spinner and sets aria-busy.

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

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

<template>
  <div class="row">
    <VIconButton
      v-for="variant in variants"
      :key="variant"
      :icon="notifications"
      :variant="variant"
      disabled
      :label="`Notifications, ${variant} disabled`"
    />
  </div>

  <div class="row">
    <VIconButton :icon="notifications" loading label="Refreshing" />
    <VIconButton :icon="notifications" variant="outline" loading label="Checking" />
    <VIconButton :icon="notifications" variant="ghost" loading label="Loading" />
  </div>
</template>

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

Router

VIconButton 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>
  <VIconButton :href="href" icon="settings" label="Settings" @click="navigate" />
</RouterLink>

API

Props

PropTypeDefault
labelstringnone
Accessible name, applied as aria-label. Name the action, such as “Close” or “Next month”.
variantButtonVariant'solid' | 'outline' | 'ghost' | 'soft''ghost'
Visual style. Uses the same values as VButton. Overridden when VButtonGroup sets a variant.
toneButtonTone'accent' | 'neutral' | 'danger''neutral'
Action intent. When omitted, uses the group’s tone or neutral if the group has none.
elevatedbooleanfalse
Adds a shadow and, for ghost and outline, a background. Overridden when the group sets elevated.
sizeButtonSize'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
Button size. Overridden when the group sets size.
shapeIconButtonShape'square' | 'circular''square'
Square or circular shape. The width and height remain equal.
hrefstringnone
Link destination. 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 the icon or default slot content with a spinner.
iconIconSourcenone
Icon to display. Accepts an IconSource. Takes precedence over the default slot.
iconFilledbooleanfalse
Requests a filled version of icon, where supported. Does not affect slot content.

Slots

SlotType
default{}
Icon content, used when icon is absent. Add aria-hidden="true" to decorative content.

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