On this page

Icon button

Live examples of Icon button, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz.

Subtle, with a tooltip

The usual icon button: Subtle, square, 12 px apart, with its name written once, in a tooltip that serves as its label.

IconButtonBasic.vue
<script setup lang="ts">
import { Ellipsis, ListFilter, RefreshCw, Trash2 } from '@lucide/vue'
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'

const tools = [
  { label: 'Sync now', icon: RefreshCw },
  { label: 'Filter', icon: ListFilter },
  { label: 'More actions', icon: Ellipsis },
]
</script>

<template>
  <TooltipProvider>
    <ButtonGroup variant="spaced" aria-label="Mapping tools">
      <Tooltip v-for="tool in tools" :key="tool.label" relationship="label">
        <TooltipTrigger as-child>
          <Button variant="ghost" size="icon">
            <component :is="tool.icon" />
          </Button>
        </TooltipTrigger>
        <TooltipContent>{{ tool.label }}</TooltipContent>
      </Tooltip>
      <Tooltip relationship="label">
        <TooltipTrigger as-child>
          <Button variant="ghost-destructive" size="icon">
            <Trash2 />
          </Button>
        </TooltipTrigger>
        <TooltipContent>Delete mapping</TooltipContent>
      </Tooltip>
    </ButtonGroup>
  </TooltipProvider>
</template>

Sizes and emphasis

Squares of 24, 32 and 40 px. Default where the button must look like a control, Primary only for the one main action.

IconButtonSizes.vue
<script setup lang="ts">
import { Plus } from '@lucide/vue'
import { Button } from '@/components/ui/button'
</script>

<template>
  <div class="flex items-center gap-(--bh-space-150)">
    <Button variant="outline" size="icon-sm" aria-label="Add field"><Plus /></Button>
    <Button variant="outline" size="icon" aria-label="Add field"><Plus /></Button>
    <Button variant="outline" size="icon-lg" aria-label="Add field"><Plus /></Button>
    <Button size="icon" aria-label="Add field"><Plus /></Button>
    <Button variant="outline" size="icon" aria-label="Add field" disabled><Plus /></Button>
  </div>
</template>

Close

The Close preset: Subtle, top right of a dialog or panel, named “Close”. Esc closes too.

Connect an online store

Sign in to the store to let HexaSync read orders and products.

IconButtonClose.vue
<script setup lang="ts">
import { X } from '@lucide/vue'
import { Button } from '@/components/ui/button'
</script>

<template>
  <section
    aria-labelledby="close-demo-title"
    class="w-full max-w-100 rounded-(--bh-radius-card) border-(length:--bh-border-width-default) border-(--bh-color-border) bg-(--bh-color-surface-overlay) p-(--bh-space-200)"
  >
    <header class="flex items-start justify-between gap-(--bh-space-200)">
      <h3 id="close-demo-title" class="m-0 [font:var(--bh-font-heading-small)]">Connect an online store</h3>
      <Button variant="ghost" size="icon" aria-label="Close"><X /></Button>
    </header>
    <p class="mt-(--bh-space-100) mb-0">Sign in to the store to let HexaSync read orders and products.</p>
  </section>
</template>

Copy

The Copy preset: after a click the icon turns into a check for 2 seconds and a polite live region says “Copied”. No toast.

API keyhx_live_4f9a2c7e81d0
IconButtonCopy.vue
<script setup lang="ts">
import { CopyButton } from '@/components/ui/copy-button'

const apiKey = 'hx_live_4f9a2c7e81d0'
</script>

<template>
  <div class="flex items-center gap-(--bh-space-100)">
    <span class="[font:var(--bh-font-label-default)]">API key</span>
    <code class="rounded-(--bh-radius-control-small) bg-(--bh-color-background-neutral) px-(--bh-space-100) py-(--bh-space-025)">{{ apiKey }}</code>
    <CopyButton :value="apiKey" label="Copy API key" copied-label="Copied" />
  </div>
</template>