Skip to content

Commit

Permalink
feat: handle basic element attributes for CheckboxButtons
Browse files Browse the repository at this point in the history
  • Loading branch information
skinread committed Dec 17, 2024
1 parent 7e451bd commit db28619
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/components/CheckboxButtons/CheckboxButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { type CheckboxGroupState, useCheckboxGroupState } from 'react-stately';
import { groupLabel } from './CheckboxButtons.css';
import { CheckboxItem, SplitLabel } from './CheckboxItem';

export interface CheckboxButtonsProps extends AriaCheckboxGroupProps {
type ElementAttributes = Pick<
React.ComponentPropsWithRef<'div'>,
'className' | 'ref' | 'style'
>;

export interface CheckboxButtonsProps
extends AriaCheckboxGroupProps,
ElementAttributes {
/**
* Label for the CheckboxButtons group needs to be provided at the component level for accessibility
*/
Expand Down Expand Up @@ -41,15 +48,16 @@ export const CheckboxButtonsContext = createContext<CheckboxGroupState | null>(
* Future enhancements might include: validation states/error handling
*/
export const CheckboxButtons = (props: CheckboxButtonsProps) => {
const { children, label, description } = props;
const { children, className, description, label, ref, style } = props;
const elementAttrs = { className, ref, style };
const state = useCheckboxGroupState(props);
const { groupProps, labelProps, descriptionProps } = useCheckboxGroup(
props,
state,
);

return (
<div {...groupProps}>
<div {...elementAttrs} {...groupProps}>
<div {...labelProps} className={groupLabel()}>
{label}
</div>
Expand Down

0 comments on commit db28619

Please sign in to comment.