On this page

Button

Live buttons for every variant, size and state, with the exact Vue file that renders each one.

Every example is a complete Vue file that uses the Beehexa Button for shadcn-vue, the same component as on the Code tab. Copy it into an app that has the registry installed, or open it in StackBlitz to edit it.

Emphasis

One primary button for the main action, default buttons for the rest, subtle buttons where a border would add noise.

ButtonEmphasis.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
</script>

<template>
  <ButtonGroup variant="spaced" aria-label="Connection actions">
    <Button>Save connection</Button>
    <Button variant="outline">Test connection</Button>
    <Button variant="ghost">View logs</Button>
  </ButtonGroup>
</template>

Danger

A danger button confirms an action that deletes data or can’t be undone. Inside a table row, use the danger tone on a subtle button.

ButtonDanger.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
import { Trash } from '@lucide/vue'
</script>

<template>
  <ButtonGroup variant="spaced" aria-label="Connection actions">
    <Button variant="destructive">Delete connection</Button>
    <Button variant="ghost-destructive"><Trash />Remove</Button>
  </ButtonGroup>
</template>

Sizes

Match the height of the fields next to the button: small (24 px) in dense tables and toolbars, default (32 px) everywhere else, large (40 px) on sign-in and onboarding pages.

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

<template>
  <div class="flex flex-wrap items-center gap-(--bh-space-100)">
    <Button variant="outline" size="sm">Small</Button>
    <Button variant="outline">Default</Button>
    <Button variant="outline" size="lg">Large</Button>
  </div>
</template>

With an icon

The icon goes before the label. A trailing icon is only for an external link or a menu chevron. Icons are decorative; Lucide marks them aria-hidden.

ButtonWithIcon.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
import { ExternalLink, Plus, RefreshCw } from '@lucide/vue'
</script>

<template>
  <ButtonGroup variant="spaced" aria-label="Sync actions">
    <Button><RefreshCw />Sync now</Button>
    <Button variant="outline"><Plus />Add mapping</Button>
    <Button variant="ghost" as="a" href="https://beehexa.design/" target="_blank" rel="noopener noreferrer">
      Open docs<ExternalLink /><span class="sr-only">(opens in a new tab)</span>
    </Button>
  </ButtonGroup>
</template>

Icon only

Square, with the same height as a button. The name goes in aria-label and also shows on hover and focus. Icon-only buttons in a row sit 12 px apart. See also Icon button.

ButtonIconOnly.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
import { Ellipsis, RefreshCw, Trash } from '@lucide/vue'
</script>

<template>
  <ButtonGroup variant="spaced" aria-label="Mapping actions">
    <Button variant="ghost" size="icon" aria-label="Sync now" title="Sync now"><RefreshCw /></Button>
    <Button variant="ghost" size="icon" aria-label="More actions" title="More actions" aria-haspopup="menu" aria-expanded="false"><Ellipsis /></Button>
    <Button variant="ghost-destructive" size="icon-sm" aria-label="Delete mapping" title="Delete mapping"><Trash /></Button>
  </ButtonGroup>
</template>

Loading

The button keeps its colours and its focus. After 1 second a spinner takes the icon’s place, the label says what is happening, and clicks are ignored until the work ends.

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

<template>
  <Button loading><RefreshCw />Syncing…</Button>
</template>

Unavailable, with the reason

When an action can’t run yet, keep the button focusable with aria-disabled and give the reason in a tooltip, as Cloudscape (disabledReason) and Fluent do. Systems differ here: Primer explains in a dialog when the button is pressed, and Atlassian puts no tooltip on a disabled button, because a natively disabled button cannot take focus. Keyboard users reach it, and the tooltip opens on focus as well as on hover.

ButtonUnavailable.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
</script>

<template>
  <TooltipProvider>
    <Tooltip>
      <TooltipTrigger as-child>
        <Button aria-disabled="true">Run sync</Button>
      </TooltipTrigger>
      <TooltipContent>Connect an online store first.</TooltipContent>
    </Tooltip>
  </TooltipProvider>
</template>

Disabled

Native disabled removes the button from the tab order. Use it only for a short wait the user already understands, such as while a form loads.

ButtonDisabled.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
</script>

<template>
  <ButtonGroup variant="spaced" aria-label="Connection actions">
    <Button disabled>Save connection</Button>
    <Button variant="outline" disabled>Test connection</Button>
    <Button variant="ghost" disabled>View logs</Button>
  </ButtonGroup>
</template>

Full width

For narrow panels and phone screens, such as the sign-in form.

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

<template>
  <div class="w-full max-w-80">
    <Button size="lg" type="submit" class="w-full">Sign in</Button>
  </div>
</template>

Order in a dialog and on a page

In dialogs, drawers and wizard footers, buttons sit at the end and the primary button comes last. In a page form, they sit at the start and the primary button comes first.

ButtonOrder.vue
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
</script>

<template>
  <div class="flex w-full flex-col gap-(--bh-space-300)">
    <ButtonGroup variant="spaced" class="justify-end" aria-label="Dialog actions">
      <Button variant="outline">Cancel</Button>
      <Button>Connect</Button>
    </ButtonGroup>
    <ButtonGroup variant="spaced" aria-label="Form actions">
      <Button type="submit">Save changes</Button>
      <Button variant="ghost">Discard</Button>
    </ButtonGroup>
  </div>
</template>

When the button goes to another page, render it as an a element with as=“a”. It keeps link behaviour: open in a new tab, copy the address.

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

<template>
  <Button variant="outline" as="a" href="/components/button/usage/">Read the usage guide</Button>
</template>

An action inside a sentence. Always underlined.

No account yet?

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

<template>
  <p class="m-0 text-(--bh-color-text) [font:var(--bh-font-body-default)]">
    No account yet? <Button variant="link">Request access</Button>
  </p>
</template>