Skip to content

fix(solid): make tooltip trigger work as expected#573

Open
pedrodesu wants to merge 1 commit into
chakra-ui:mainfrom
pedrodesu:main
Open

fix(solid): make tooltip trigger work as expected#573
pedrodesu wants to merge 1 commit into
chakra-ui:mainfrom
pedrodesu:main

Conversation

@pedrodesu

@pedrodesu pedrodesu commented Jul 5, 2026

Copy link
Copy Markdown

Description

This PR implements an asChild equivalent for the Trigger component in the Solid.js implementation to align its API with the React version.

The Issue

As of now, the Solid.js Trigger is hardcoded to wrap its children in a structural container (<Trigger>{children}</Trigger>). Unlike the React implementation, which utilizes an asChild prop to allow consumers to bypass this wrapper and merge trigger functionality onto their own components, the Solid.js version lacks this flexibility. This limits consumer control over the underlying DOM structure and makes it difficult to integrate custom button components. You either end up with nested button elements with different functionalities, or lose functionality.

The Solution

This change introduces an asChild support pattern within the Solid.js Trigger wrapper. It now detects if a function (render prop) is passed as a child.

  • If a function is provided, the component passes the necessary trigger props to that function, allowing consumers to spread them onto their own elements (mimicking the React asChild behavior).
  • If a standard element is provided, it falls back to the original behavior, wrapping the content in the default Trigger container.

This ensures full parity with the React implementation and improves component composability.

Before:

<Tooltip>
  <Button>Click me</Button>
</Tooltip>
// Result: <button><button>Click me</button></button>

After:

<Tooltip>
  {props => <Button {...props()}>Click me</Button>}
</Tooltip>
// Result: <button>Click me</button> (Props and functionality merged seamlessly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant