Group related buttons into a connected unit with shared corners and seams, with complete control over layout and styling.
Features#
- Groups multiple
Buttoncomponents into a single connected unit - Works with the standard
ButtonAPI
Usage#
import { Button } from 'primereact/button';
import { ButtonGroup } from 'primereact/buttongroup';<ButtonGroup>
<Button>Save</Button>
<Button>Update</Button>
<Button>Delete</Button>
</ButtonGroup>API#
ButtonGroup#
| Name | Type | Default |
|---|---|---|
ref | Ref<unknown> | — |
| The reference to the component instance. | ||
pIf | boolean | true |
| Whether the component should be rendered. | ||
style | CSSProperties | ((instance?: ButtonGroupInstance) => undefined | CSSProperties) | — |
| The style to apply to the component. | ||
className | string | ((instance?: ButtonGroupInstance) => undefined | string) | — |
| The class name to apply to the component. | ||
as | null | string | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode> | — |
| The component type to render. | ||
asChild | boolean | false |
| Whether the component should be rendered as a child component. | ||
instance | ButtonGroupInstance | — |
| The instance to pass to the component. | ||
pt | SafeRecord<ButtonGroupPassThrough> | — |
| The pass-through props to pass to the component. | ||
ptOptions | PassThroughOptions | — |
| The pass-through options to pass to the component. | ||
unstyled | boolean | — |
| Whether the component should be rendered without classes. | ||
dt | unknown | — |
| The design token to use for the component. | ||
styles | StylesOptions<ComponentInstance> | — |
| The styles to use for the component. | ||
render | (instance: ButtonGroupInstance) => ReactNode | — |
| The render function to render the component with instance access. | ||
children | any | — |
| The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates. | ||
[key: string] | any | — |
pt-{optionName}-* | - | — |
| Pass through attributes for customizing component. For more info, see Pass Through tab. | ||
Defines passthrough(pt) options of Button component.
| label | type | description |
|---|---|---|
| root | ButtonGroupPassThroughType<HTMLAttributes<HTMLDivElement>> | Used to pass attributes to the root's DOM element. |
Accessibility#
Screen Reader#
ButtonGroup does not require any roles and attributes. Each Button keeps its native semantics; provide an accessible name for icon-only buttons with aria-label.
Keyboard Support#
Each button inside the group is focusable and activated with enter or space.