We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
id
label
1 parent a27887e commit 3a49bacCopy full SHA for 3a49bac
src/scripts/Checkbox.tsx
@@ -2,6 +2,7 @@ import React, {
2
FC,
3
InputHTMLAttributes,
4
Ref,
5
+ useId,
6
useContext,
7
ReactNode,
8
} from 'react';
@@ -32,7 +33,7 @@ export type CheckboxProps = {
32
33
export const Checkbox: FC<CheckboxProps> = (props) => {
34
const {
35
type, // eslint-disable-line @typescript-eslint/no-unused-vars
- id,
36
+ id: id_,
37
className,
38
label,
39
required,
@@ -45,6 +46,9 @@ export const Checkbox: FC<CheckboxProps> = (props) => {
45
46
...rprops
47
} = props;
48
49
+ const prefix = useId();
50
+ const id = id_ ?? `${prefix}-id`;
51
+
52
const { grouped, error, errorId } = useContext(CheckboxGroupContext);
53
const formElemProps = {
54
0 commit comments