Replies: 2 comments 1 reply
-
Hi @terlan4, Normally you want to forward the props and ref when you want to compose your own component with some part of some Radix component. A good example of this is when you already have your button component and want to use it instead of The reason you need to pass all the props and the ref - actually, you only need to pass the props that that part of the component, like the So, taking your example 1 and 2 where you want to composite the // Button.tsx
const MyButton = React.forwardRef((props, ref) => (
<button {...props} ref={ref} />
)) <Toolbar.Root>
<Tooltip.Root>
<Toolbar.Button asChild>
<Tooltip.Trigger asChild>
<MyButton>Button</MyButton>
</Tooltip.Trigger>
</Toolbar.Button>
<Tooltip.Content>
{ ... }
</Tooltip.Content>
</Tooltip.Root>
{ ... }
</Toolbar.Root> If you don't have your own component and are using the normal button tag, the In your third example, I don't see the need to forward the props and the reference. Unless you're going to compose I hope it was clear! If you still have questions, don't hesitate to ask. I would be happy to help you! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions