Is it advisable to use asChild prop on ToggleGroupItem with Toggle component inside #1210
Answered
by
jjenzz
joseDaKing
asked this question in
Help
-
I have many components that look the same and have the same styles, which I think is unnecessary that's why I wonder if it is possible and advisable to compose radix components with each other via the asChild prop. const App = () => {
return (
<ToggleGroup.Root>
<ToggleGroup.Item asChild>
<Toggle>
</ToggleGroup.Item>
</ToggleGroup.Root>
);
} |
Beta Was this translation helpful? Give feedback.
Answered by
jjenzz
Feb 28, 2022
Replies: 1 comment
-
As long as you are using all of the required parts from each component, it should be fine to compose them using |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
joseDaKing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As long as you are using all of the required parts from each component, it should be fine to compose them using
asChild
if the underlying node type is the same. For example,ToggleGroup.Item
is abutton
so the child should ideally be abutton
too otherwise you may face accessibility/functionality issues.