question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use tippyjs with custom attribute (instead of title)

See original GitHub issue

Hey Guys, 😃

I’m trying to use tippyjs with attribute other than title, something like: selector: [rel-tooltip] tooltip content: [tooltip]

This is my current setup:

	tippy('[title]', {
		arrow: true,
		animation: 'fade',
		theme: 'general',
		delay: [0, 0],
		duration: [0, 0],
		maxWidth: '210px',
		dynamicTitle: true
	});

I’m using the library on chromium app with a lot of dynamic content and pages sometimes between destroy and initialization of the library the default behavior of the title attribute come up and I’m trying to get rid of it.

I tried this with no luck:

	tippy('[rel-tooltip]', {
		arrow: true,
		animation: 'fade',
		theme: 'general',
		delay: [0, 0],
		duration: [0, 0],
		maxWidth: '210px',
                content: '[tooltip]'
		dynamicTitle: true
	});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
anthony0579commented, Feb 10, 2019

All working great - thanks!

1reaction
atomikscommented, Feb 10, 2019

If you want this as default behavior, feel free to “enhance” the tippy function.

function withTitleAttributeContent(tippy) {
  return (targets, options = {}) => tippy(targets, {
    ...options,
    content(reference) {
      if (options.content) {
        return options.content
      }
      const title = reference.getAttribute('title')
      reference.removeAttribute('title')
      return title
    }
  })
}

window.tippy = withTitleAttributeContent(tippy)
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the title attribute as the content for Tippy.js?
Based on the documentation, you can use reference.getAttribute('title'). Ex.: tippy('#myButton, { content: (reference) => reference.
Read more >
FAQ | Tippy.js - GitHub Pages
Can I use the title attribute? Yes. The content prop can be a function that receives the reference element as an argument and...
Read more >
Creating Tooltips | Tippy.js
The data-tippy-content attribute allows you to give different tooltip content to many different elements, while only needing to initialize once.
Read more >
All Props | Tippy.js
"Props" are configurable properties you can pass optionally to the tippy() constructor ... Determines if content strings are parsed as HTML instead of...
Read more >
Tippy.js - Tooltip, Popover, Dropdown, and Menu Library
These themes are included in the package and can be imported separately. light light-border material translucent. #Custom themes. You can apply any CSS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found