checkbox_group/checkbox_cards are missing most of the props radio_group/radio_cards already expose
Describe the Features
checkbox_group.root and checkbox_cards.root both wrap the same internal
CheckboxGroupPrimitive.Root (checkbox-group.primitive.tsx in @radix-ui/themes), whose real
prop surface is value, defaultValue, onValueChange, disabled, required, name,
asChild, orientation, dir, and loop. radio_group.root/radio_cards.root already expose
essentially all of these for their own analogous underlying primitive -- but the checkbox side is
missing most of them:
checkbox_group.rootcurrently exposes onlydefault_valueandname. Missing:value(so it can't be used as a controlled component at all),on_value_change,disabled,required,as_child,orientation,dir,loop.checkbox_cards.rootexposes none of the form-control props -- not evenname,disabled,value, ordefault_value.checkbox_cards.itemhas no declared props whatsoever, so a checkbox card can't even be given avalue-- it's currently unusable for real form submission.checkbox_group.item/checkbox_cards.itemare also missingrequired, whichradio_group.item/radio_cards.itemalready have.
One concrete, currently-impossible use case: a controlled multi-select checkbox group
(value=State.selected, on_value_change=State.set_selected) -- rx.radio_group supports the
controlled-value equivalent today, rx.checkbox_group does not.
Separately, CheckboxCardsRoot was never marked _is_form_control = True, so unlike
checkbox_group/radio_group/radio_cards/select/switch/both sliders (see
packages/reflex-components-radix/CHANGELOG.md's note on #6301), a checkbox_cards.root's name
is never picked up when a form validates its fields against a TypedDict-annotated on_submit
handler. That PR's changelog entry lists every other form control except checkbox cards -- this
looks like it was simply skipped at the time because checkbox_cards.root had no name/value
prop yet to report.
Why are you requesting this feature?
Found while fixing a related rx.form bug (a multi-value FormData submit issue) and noticing
checkbox_group/checkbox_cards are the only two form controls in this package that can't be used
as controlled components or participate in typed form validation, even though their direct sibling
components (radio_group, radio_cards) already support exactly this.
What is your proposed implementation for this feature?
Add the missing props directly, matching radio_group.root/radio_cards.root's existing field
declarations for the equivalent primitive props: value, on_value_change
(EventHandler[passthrough_event_spec(list[str])], matching the existing
toggle_group/accordion precedent for a list-valued onValueChange), disabled, required,
as_child, orientation, dir, loop on both roots; name/default_value additionally on
checkbox_cards.root; required on both item classes; value/disabled additionally on
checkbox_cards.item. Also sets CheckboxCardsRoot._is_form_control = True. I've already
implemented, tested, and verified all of this -- happy to open a PR immediately if the direction is
welcome.
Source: reflex-dev/reflex