Skip to content

react-tooltip optional button usage #3769

@monaghancj

Description

@monaghancj

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions