feat(button): add default role for aria

This commit is contained in:
p-sw 2024-07-19 00:34:42 +09:00
parent 6c14cb1e51
commit bc2020f560

View File

@ -111,7 +111,8 @@ export interface ButtonProps
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
(props, ref) => { (props, ref) => {
const [variantProps, otherPropsCompressed] = resolveVariants(props); const [variantProps, otherPropsCompressed] = resolveVariants(props);
const { asChild, type, ...otherPropsExtracted } = otherPropsCompressed; const { asChild, type, role, ...otherPropsExtracted } =
otherPropsCompressed;
const Comp = asChild ? Slot : "button"; const Comp = asChild ? Slot : "button";
@ -120,6 +121,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
ref={ref} ref={ref}
type={type ?? "button"} type={type ?? "button"}
className={buttonVariants(variantProps)} className={buttonVariants(variantProps)}
role={role ?? "button"}
{...otherPropsExtracted} {...otherPropsExtracted}
/> />
); );