CheckboxGroup with indeterminate/select all checkbox #5215
Replies: 2 comments
-
I don't think you can accomplish this right now due to context control of selected states. We could consider adding it, we'll need to check if there are any accessibility concerns. We'd also need to determine what the API would look like, if we handle it at the group level or on individual checkboxes like you've tried here. For now you'll need to separate the select all from the rest of the group. |
Beta Was this translation helpful? Give feedback.
-
It's a little hacky I guess, but if you need the select all checkbox to be within the checkbox group in the DOM, you can escape the CheckboxGroup managed state setting the <CheckboxGroupStateContext.Provider value={null}>
<MyCheckbox
isIndeterminate={indeterminate}
isSelected={allSelected}
onChange={(isSelected) => setSelected(isSelected ? ["subscribe", "test", "another"] : [])}>
Select all
</MyCheckbox>
</CheckboxGroupStateContext.Provider> |
Beta Was this translation helpful? Give feedback.
-
Hi team. First off, great work on the react-aria-components work. I'm really enjoying seeing it grow. I'm working on using the Checkbox and CheckboxGroup components, and am struggling with coming up with a way to have a select all option with an indeterminate state. Here's what I have so far, but something just isn't clicking. I didn't see an example on the doc site, but do you have one worked up somewhere else?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions