PrimeUI PRO for React is now available 🚀View Demos

ButtonGroup

An unstyled container that groups related buttons into a single connected unit.

Group related buttons into a connected unit with shared corners and seams, with complete control over layout and styling.

Features#

  • Groups multiple Button components into a single connected unit
  • Works with the standard Button API

Usage#

import { Button } from 'primereact/button';
import { ButtonGroup } from 'primereact/buttongroup';
<ButtonGroup>
    <Button>Save</Button>
    <Button>Update</Button>
    <Button>Delete</Button>
</ButtonGroup>

API#

ButtonGroup#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: ButtonGroupInstance) => undefined | CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: ButtonGroupInstance) => undefined | string)—
The class name to apply to the component.
asnull | 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.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceButtonGroupInstance—
The instance to pass to the component.
ptSafeRecord<ButtonGroupPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: ButtonGroupInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
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.

labeltypedescription
rootButtonGroupPassThroughType<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.