A component that joins several buttons into one control. This is a custom component with no Base UI primitive. Each child Button keeps its variant and size, and only the outer corners of the group are rounded.
Here is the component implementation code that you can copy to your project:
// https://devie-ui.com/components/button-group
import clsx from "clsx";
import type React from "react";
import styles from "./ButtonGroup.module.scss";
function ButtonGroup({ className, ...props }: ButtonGroup.Props) {
return <fieldset className={clsx(styles.group, className)} {...props} />;
}
namespace ButtonGroup {
export type Props = React.ComponentProps<"fieldset">;
}
export default ButtonGroup;Wrap two or more Button elements in ButtonGroup. Set aria-label to name the group.
Pair a primary action with a Menu trigger. Pass an icon Button to the trigger render prop and give it an aria-label.
Use the icon-secondary variant for a compact group. Each button needs an aria-label.
Set the same size on every button in a group.