ButtonGroup
Group multiple button-like elements together.
Usage
Wrap multiple Button within a ButtonGroup to group them together.
<template>
<UButtonGroup>
<UButton color="neutral" variant="subtle" label="Button" />
<UButton color="neutral" variant="outline" icon="i-lucide-chevron-down" />
</UButtonGroup>
</template>
Size
Use the size
prop to change the size of all the buttons.
<template>
<UButtonGroup size="xl">
<UButton color="neutral" variant="subtle" label="Button" />
<UButton color="neutral" variant="outline" icon="i-lucide-chevron-down" />
</UButtonGroup>
</template>
Orientation
Use the orientation
prop to change the orientation of the buttons. Defaults to horizontal
.
<template>
<UButtonGroup orientation="vertical">
<UButton color="neutral" variant="subtle" label="Submit" />
<UButton color="neutral" variant="outline" label="Cancel" />
</UButtonGroup>
</template>
Examples
With input
You can use components like Input, InputMenu, Select SelectMenu, etc. within a button group.
<template>
<UButtonGroup>
<UInput color="neutral" variant="outline" placeholder="Enter token" />
<UButton color="neutral" variant="subtle" icon="i-lucide-clipboard" />
</UButtonGroup>
</template>
With tooltip
You can use a tooltip within a button group.
<template>
<UButtonGroup>
<UInput color="neutral" variant="outline" placeholder="Enter token" />
<UTooltip text="Copy to clipboard">
<UButton
color="neutral"
variant="subtle"
icon="i-lucide-clipboard"
/>
</UTooltip>
</UButtonGroup>
</template>
With dropdown
You can use a dropdown menu within a button group.
<script setup lang="ts">
const items = [{
label: 'Team',
icon: 'i-lucide-users'
}, {
label: 'Invite users',
icon: 'i-lucide-user-plus',
children: [{
label: 'Invite by email',
icon: 'i-lucide-send-horizontal'
}, {
label: 'Invite by link',
icon: 'i-lucide-link'
}]
}, {
label: 'New team',
icon: 'i-lucide-plus'
}]
</script>
<template>
<UButtonGroup>
<UButton color="neutral" variant="subtle" label="Settings" />
<UDropdownMenu :items="items">
<UButton
color="neutral"
variant="outline"
icon="i-lucide-chevron-down"
/>
</UDropdownMenu>
</UButtonGroup>
</template>
API
Props
Prop | Default | Type |
---|---|---|
as |
|
The element or component this component should render as. |
size |
| |
orientation |
|
The orientation the buttons are laid out. |
Slots
Slot | Type |
---|---|
default |
|
Theme
app.config.ts
export default defineAppConfig({
ui: {
buttonGroup: {
base: 'relative',
variants: {
size: {
xs: '',
sm: '',
md: '',
lg: '',
xl: ''
},
orientation: {
horizontal: 'inline-flex -space-x-px',
vertical: 'flex flex-col -space-y-px'
}
}
}
}
})