Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 5c060e9

Browse files
fix: type naming conventions and allow label to accept any ReactNode
1 parent 8d2a0f1 commit 5c060e9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/components/Checkbox.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import type { CheckboxProps, ToggleProps } from '@react-types/checkbox';
1+
import type {
2+
CheckboxProps as RTCheckboxProps,
3+
ToggleProps,
4+
} from '@react-types/checkbox';
25
import { gsap } from 'gsap';
3-
import type { ComponentPropsWithRef } from 'react';
6+
import type { ComponentPropsWithRef, ReactNode } from 'react';
47
import { useEffect, useRef } from 'react';
58
import { useCheckbox } from 'react-aria';
69
import { useToggleState } from 'react-stately';
@@ -67,19 +70,18 @@ const IconContainer = styled('div', {
6770
transform: 'translate(-50%, -50%)',
6871
});
6972

70-
type CustomCheckboxProps = {
71-
text?: string;
73+
type CheckboxProps = RTCheckboxProps & {
74+
label?: ReactNode;
7275
};
73-
7476
export const Checkbox = ({
7577
validationState,
76-
text,
78+
label,
7779
defaultSelected,
7880
isIndeterminate,
7981
...restProps
8082
}: CheckboxProps &
8183
ComponentPropsWithRef<'input'> &
82-
CustomCheckboxProps &
84+
RTCheckboxProps &
8385
ToggleProps) => {
8486
const ref = useRef<HTMLInputElement>(null);
8587
const { isSelected, toggle, setSelected } = useToggleState({
@@ -117,7 +119,7 @@ export const Checkbox = ({
117119
<IconContainer>
118120
<CheckIcon strokeDashoffset={isSelected ? '' : '21'} />
119121
</IconContainer>
120-
{text}
122+
{label}
121123
</Label>
122124
);
123125
};

0 commit comments

Comments
 (0)