Skip to content

New render tooltip prop to allow for more customization#975

Merged
gabrieljablonski merged 3 commits intomasterfrom
feat/render-prop
Mar 9, 2023
Merged

New render tooltip prop to allow for more customization#975
gabrieljablonski merged 3 commits intomasterfrom
feat/render-prop

Conversation

@gabrieljablonski
Copy link
Copy Markdown
Member

Closes #949

Signature:

render?: (render: {
  content: string | null
  activeAnchor: HTMLElement | null
}) => ChildrenType

Usage example:

<a data-tooltip-id="my-tooltip" data-tooltip-content="my-content" />
<Tooltip
  id="my-tooltip"
  render={({ content, activeAnchor }) => (
    <>
      content={content} from anchor with id={activeAnchor?.id}
    </>
  )}
/>

content comes from data-tooltip-content on the anchor.

@gabrieljablonski gabrieljablonski changed the title New render tooltip prop to allow for more customization New render tooltip prop to allow for more customization Mar 9, 2023
Copy link
Copy Markdown
Member

@danielbarion danielbarion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me! great job :)

@gabrieljablonski gabrieljablonski merged commit 06696b2 into master Mar 9, 2023
@gabrieljablonski gabrieljablonski deleted the feat/render-prop branch March 9, 2023 18:22
@j-greig
Copy link
Copy Markdown

j-greig commented Aug 12, 2023

Got this working with an API call inside the tooltip to fetch live data, nice 🤝

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT REQ] Better way to render custom content based on the active anchor element

3 participants