diff --git a/packages/ui/src/CheckboxInput/CheckboxInput.tsx b/packages/ui/src/CheckboxInput/CheckboxInput.tsx index edeb9d3a..fec43b7e 100644 --- a/packages/ui/src/CheckboxInput/CheckboxInput.tsx +++ b/packages/ui/src/CheckboxInput/CheckboxInput.tsx @@ -7,6 +7,7 @@ type Props = Readonly<{ defaultValue?: boolean; description?: string; disabled?: boolean; + errorMessage?: string; label: string; name?: string; onChange?: ( @@ -21,6 +22,7 @@ function CheckboxInput( defaultValue, description, disabled = false, + errorMessage, label, name, value, @@ -30,59 +32,67 @@ function CheckboxInput( ) { const id = useId(); const descriptionId = useId(); + const errorId = useId(); return ( -
-
- { - onChange?.(event.target.checked, event); - } - : undefined - } - /> -
-
- - {description && ( -

+

+
+ - {description} -

- )} + defaultChecked={defaultValue} + disabled={disabled} + id={id} + name={name} + type="checkbox" + onChange={(event) => { + if (!onChange) { + return; + } + + onChange(event.target.checked, event); + }} + /> +
+
+ + {description && ( +

+ {description} +

+ )} +
+ {errorMessage && ( +

+ {errorMessage} +

+ )}
); }