-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Feature request
When using the react-tooltip, the tooltip component should only use a button element if children (or asChild) is passed in.
Overview
User's typically wrap button elements with a Tooltip. This results in a react error as you can't have a button within a button. It seems that radix composition allows this, using the asChild prop on the Trigger primitive from Tooltip.
Ideally, by existence of a button element as a child of element of the Trigger, or using the existing asChild prop (or a new, explicit prop), the Trigger component can optionally utilize a button element, use the children passed in or wrap the children in a different element for better control.
Examples in other libraries
Other libraries don't use button under the hood.
https://mui.com/material-ui/react-tooltip/
Who does this impact? Who is this for?
The most typical element for a user to "optionally" wrap with a tooltip, is a native button element. So this is for all users.
Additional context
https://www.radix-ui.com/primitives/docs/guides/composition
https://www.radix-ui.com/primitives/docs/components/tooltip#trigger