Should react-aria hooks expose data attributes in props? #5632
-
The Button component from However, when customising the component (as recommended here: https://react-spectrum.adobe.com/react-aria/Button.html#hooks ), I'm not getting the data attributes when using What would be the right approach if I wanted to keep these data attributes & apply them to a custom component? (Like you would do with polymorphism or a Repro: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey, thanks for the discussion. We have soft decided not to include the data-attributes because it would be more opinionated and the hooks are meant to be general. We do recognize that it might make the "dropping down" to the hooks, from RAC specifically, a bit easier, but figured we'd hold off in the initial release to see how common it is in practice. The right approach right now would be to add the appropriate hooks and create the data-attributes yourself. You can look at the source or docs for a given RAC component in order to see which ones should be applied as well as how we apply it ourselves. This approach also allows people to more easily customize the name of the |
Beta Was this translation helpful? Give feedback.
-
Thanks @snowystinger – makes sense! Maybe the "Advanced customization" section in the docs should include extra details to mimic the RAC behaviour / props ? |
Beta Was this translation helpful? Give feedback.
Hey, thanks for the discussion. We have soft decided not to include the data-attributes because it would be more opinionated and the hooks are meant to be general.
We do recognize that it might make the "dropping down" to the hooks, from RAC specifically, a bit easier, but figured we'd hold off in the initial release to see how common it is in practice.
The right approach right now would be to add the appropriate hooks and create the data-attributes yourself. You can look at the source or docs for a given RAC component in order to see which ones should be applied as well as how we apply it ourselves.
This approach also allows people to more easily customize the name of the
data-*
attribut…