Icon button VIconButton displays an icon for an action or link. Its required label provides the accessible name.
Usage <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.
<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.
<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.
<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.
<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.
<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> Link href renders a link. Navigation is blocked while the button is disabled or loading.
<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.
<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.
<RouterLink v-slot="{ href, navigate }" to="/settings" custom>
<VIconButton :href="href" icon="settings" label="Settings" @click="navigate" />
</RouterLink> API Props Slots 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