radix-ui / themes

Radix Themes is an open-source component library optimized for fast development, easy maintenance, and accessibility. Maintained by @workos.

Home Page:https://radix-ui.com/themes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`RadioGroup.Item` and `RadioCards.Item` accept `checked` prop

kevinmitch14 opened this issue · comments

I noticed that CheckboxCards.Item and CheckboxGroup.Item don't accept checked as a prop. Is this by design? RadioGroup and RadioCards seem to accept this, along with Checkbox.

Screenshot 2024-04-10 at 13 55 06

Yes, the value prop on the Root part is the source of truth. I'll double check the Radio Group and Radio Cards, don't think those should have the checked prop

Gotcha, in my case we are using them as a sort of stepper. So if step1 is completed, the CheckboxCards.Root value should have "step1" in it and so on.

But I can't do the following: step1Completed can be string | undefined and you can't assign undefined to string.

// Type 'string | undefined' is not assignable to type 'string'.
<CheckboxCards.Root value={[step1Completed && "step1", step2Completed && "step2"]}>

So I am doing the following to keep typescript happy but it seems like a hacky solution:

<CheckboxCards.Root value={[step1Completed ? "step1": "_", step2Completed ? "step2": "_"]}>

Edit: I'm prob not going to continue using this method, but just thought I would raise it here.