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-heroicons-chevron-down-20-solid" />
</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-heroicons-chevron-down-20-solid" />
</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-heroicons-clipboard-document" />
</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-heroicons-clipboard-document"
/>
</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-heroicons-users'
}, {
label: 'Invite users',
icon: 'i-heroicons-user-plus',
children: [{
label: 'Invite by email',
icon: 'i-heroicons-paper-airplane'
}, {
label: 'Invite by link',
icon: 'i-heroicons-link'
}]
}, {
label: 'New team',
icon: 'i-heroicons-plus'
}]
</script>
<template>
<UButtonGroup>
<UButton color="neutral" variant="subtle" label="Settings" />
<UDropdownMenu :items="items">
<UButton
color="neutral"
variant="outline"
icon="i-heroicons-chevron-down-20-solid"
/>
</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'
}
},
buttonGroupVariant: {
buttonGroup: {
horizontal: 'not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none',
vertical: 'not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none'
}
},
buttonGroupVariantWithRoot: {
buttonGroup: {
horizontal: {
root: 'group',
base: 'group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none'
},
vertical: {
root: 'group',
base: 'group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none'
}
}
}
}
}
})