Skip to content

Commit b257895

Browse files
committed
refactor(styled checkbox): improve handling of name/id props
1 parent ab463f6 commit b257895

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { PropsOf, component$ } from '@builder.io/qwik';
22
import { cn } from '@qwik-ui/utils';
33

4-
export const Checkbox = component$<PropsOf<'input'>>(({ name, ...props }) => {
4+
export const Checkbox = component$<PropsOf<'input'>>(({ id, name, ...props }) => {
5+
const inputId = id || name;
56
return (
67
<input
78
type="checkbox"
@@ -10,8 +11,7 @@ export const Checkbox = component$<PropsOf<'input'>>(({ name, ...props }) => {
1011
'peer peer h-4 w-4 shrink-0 border-primary text-primary accent-primary ring-offset-background focus:ring-ring focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
1112
props.class,
1213
)}
13-
name={name}
14-
id={name}
14+
id={inputId}
1515
/>
1616
);
1717
});

0 commit comments

Comments
 (0)