-
Hi Screenshot from: https://zagjs.com/components/react/radio-group
Also, this is problematic when trying to style focused elements, because all the children as described above gets the same focus attribute and all get the same focus style. A workaround I used was to do Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@babakfp It's because it's part of the item. When an item is focused, everything within is considered focused, your workaround is the expected way to target just the item. |
Beta Was this translation helpful? Give feedback.
The reason for propagating data-states to child elements is to support context-aware styling and accessibility. Some key cases I can point out:
Unified interaction
In components like (menus, dropdowns, or list items with multiple controls), propagating allows all parts of the item to visually respond to the state.
e.g. A focused dropdown item might highlight both the label and its checkbox or icon.
Keyboard Navigation
Accessibility specs often treat the entire item (and its parts) as a single focusable entity for keyboard navigation (e.g., Tab or ArrowKey focus). Propagating data-focus ensures consistent styling or interaction feedback.
Interdependent Styling
Some designs require child el…