Skip to content

Button Group

Set the iconOnly prop on ButtonGroup to style each button for a single icon. This is useful for compact toolbars where a row of icon buttons act as related actions. Each button is configured through the buttonsProps array, and can carry a tooltip or a dropdown.

For the full API and general (text) button groups, see Button Group.

Installation

import { ButtonGroup, IconV2, DropdownMenu } from '@harnessio/ui/components'
return (
<ButtonGroup
iconOnly
size="sm"
buttonsProps={[
{ children: <IconV2 name="info-circle" />, onClick: () => { console.log('Button icon') } },
{ children: <IconV2 name="key-back" />, tooltipProps: { title: 'Title', content: <p>This is a tooltip</p> }, onClick: () => { console.log('Button with tooltip') } },
{
children: <IconV2 name="more-vert" />,
dropdownProps: {
content: (
<>
<DropdownMenu.Item title="Item title" />
<DropdownMenu.Item title="With description" description="Item description" />
<DropdownMenu.Separator />
<DropdownMenu.Item title="With label" label="Label" />
<DropdownMenu.Item title="With checkmark" checkmark />
<DropdownMenu.Item title="With shortcut" shortcut="⇧⌘P" />
</>
)
}
}
]}
/>
)

Icon only

The ButtonGroup component accepts an iconOnly prop. When this prop is set, each button is styled to fit the dimensions of an icon, making it suitable for icon-only buttons.

With tooltip

Within buttonsProps, you can provide tooltipProps to define tooltip data for a specific button.