diff --git a/packages/actify/src/components/Checkbox/Checkbox.tsx b/packages/actify/src/components/Checkbox/Checkbox.tsx index 12898a1..ca2fe6b 100644 --- a/packages/actify/src/components/Checkbox/Checkbox.tsx +++ b/packages/actify/src/components/Checkbox/Checkbox.tsx @@ -9,32 +9,32 @@ import { } from 'react-aria' import { CheckboxGroupState, useToggleState } from 'react-stately' import React, { useId } from 'react' -import { useCheckboxGroup, useCheckboxGroupItem } from 'react-aria' import { CheckboxGroupContext } from './CheckboxGroup' import { FocusRing } from './../FocusRing' import { Label } from './../Label' import { Ripple } from './../Ripple' +import { StyleProps } from '../../utils' import clsx from 'clsx' import styles from './checkbox.module.css' +import { useCheckboxGroupItem } from 'react-aria' -interface CheckboxProps extends AriaCheckboxProps { +interface CheckboxProps extends AriaCheckboxProps, StyleProps { ref?: React.RefObject color?: 'primary' | 'secondary' | 'tertiary' | 'error' } const Checkbox = (props: CheckboxProps) => { - const _id = `actify-checkbox${useId()}` const _inputRef = React.useRef(null) - const { id = _id, ref: inputRef = _inputRef } = props + const { ref: inputRef = _inputRef } = props const groupState = React.useContext(CheckboxGroupContext) const toggleState = useToggleState(props) const state = groupState ?? toggleState - const { inputProps } = groupState + const { inputProps, labelProps } = groupState ? useCheckboxGroupItem( props as AriaCheckboxGroupItemProps, state as CheckboxGroupState, @@ -52,18 +52,14 @@ const Checkbox = (props: CheckboxProps) => { const { isFocusVisible, focusProps } = useFocusRing() return ( -