import * as React from 'react' import { cva, type VariantProps } from 'class-variance-authority' import { cn } from '@/lib/utils' const buttonGroupVariants = cva( // isolate + z-10 on focused child keeps focus ring from being clipped by siblings. 'inline-flex isolate [&>*]:focus-visible:relative [&>*]:focus-visible:z-10', { variants: { orientation: { horizontal: 'flex-row items-stretch [&>*:not(:first-child)]:-ml-px [&>*:not(:first-child)]:rounded-l-none [&>*:not(:last-child)]:rounded-r-none', vertical: 'flex-col [&>*:not(:first-child)]:-mt-px [&>*:not(:first-child)]:rounded-t-none [&>*:not(:last-child)]:rounded-b-none', }, }, defaultVariants: { orientation: 'horizontal', }, }, ) export interface ButtonGroupProps extends React.HTMLAttributes, VariantProps {} const ButtonGroup = React.forwardRef( ({ className, orientation = 'horizontal', ...props }, ref) => (
), ) ButtonGroup.displayName = 'ButtonGroup' export type ButtonGroupTextProps = React.HTMLAttributes const ButtonGroupText = React.forwardRef( ({ className, ...props }, ref) => (
), ) ButtonGroupText.displayName = 'ButtonGroupText' export interface ButtonGroupSeparatorProps extends React.HTMLAttributes { orientation?: 'horizontal' | 'vertical' } const ButtonGroupSeparator = React.forwardRef( ({ className, orientation = 'vertical', ...props }, ref) => (
), ) ButtonGroupSeparator.displayName = 'ButtonGroupSeparator' export { ButtonGroup, ButtonGroupText, ButtonGroupSeparator, buttonGroupVariants }