Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz.
Spaced
The actions at the end of a dialog: 8 px apart, primary last.
ButtonGroupSpaced.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="Dialog actions" class="justify-end">
<Button variant="outline">Cancel</Button>
<Button>Save connection</Button>
</ButtonGroup>
</template>Joined
Actions on one thing that read as one control. Only the outer corners are round; the touching borders overlap into one line.
ButtonGroupJoined.vue
<script setup lang="ts">
import { ChevronLeft, ChevronRight } from '@lucide/vue'
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
</script>
<template>
<ButtonGroup aria-label="Date range">
<Button variant="outline" size="icon" aria-label="Previous week"><ChevronLeft /></Button>
<Button variant="outline">This week</Button>
<Button variant="outline" size="icon" aria-label="Next week"><ChevronRight /></Button>
</ButtonGroup>
</template>Icon-only buttons
Icon-only buttons in a spaced group sit 12 px apart.
ButtonGroupIcons.vue
<script setup lang="ts">
import { Download, Pencil, Trash2 } from '@lucide/vue'
import { Button } from '@/components/ui/button'
import { ButtonGroup } from '@/components/ui/button-group'
</script>
<template>
<ButtonGroup variant="spaced" aria-label="Actions for this mapping">
<Button variant="ghost" size="icon-sm" aria-label="Edit mapping"><Pencil /></Button>
<Button variant="ghost" size="icon-sm" aria-label="Download log"><Download /></Button>
<Button variant="ghost-destructive" size="icon-sm" aria-label="Delete mapping"><Trash2 /></Button>
</ButtonGroup>
</template>