Home
Tutorials
How To Add Simple Tooltips In Webflow

With tooltips, you can quickly make your Webflow website more helpful for your visitors. A tooltip is the box you notice when you point or click your mouse over an icon or a word. They give you short answers, hints or explanations, right on the screen, without getting in the way or needing click actions.

Adding tooltips can help make your product guide smarter, your forms easily understandable and your site as a whole more helpful. We will show you how to build simple tooltips in Webflow using what Webflow provides, like interactions and div blocks. You’ll learn how to customize your tooltips with some extra code, should you want to take more control.

1. Add the script to your project

1.Go into your Webflow project.

2.Go to the Settings for Pages if you want tooltips on a single page or use the Site Settings for a tooltip on every page.

3.Move down to where the Before is highlighted.

4.Paste this script below:

<script>
  document.addEventListener("DOMContentLoaded", function () {
    const tooltips = document.querySelectorAll("[data-tooltip]");

    tooltips.forEach((el) => {
      const tooltipText = el.getAttribute("data-tooltip");
      const tooltip = document.createElement("div");
      tooltip.className = "custom-tooltip";
      tooltip.innerText = tooltipText;
      document.body.appendChild(tooltip);

      el.addEventListener("mouseenter", () => {
        tooltip.style.display = "block";
        const rect = el.getBoundingClientRect();
        tooltip.style.left = rect.left + window.scrollX + "px";
        tooltip.style.top = rect.top + window.scrollY - 30 + "px";
      });

      el.addEventListener("mouseleave", () => {
        tooltip.style.display = "none";
      });
    });
  });
</script>

2. Add tooltip attributes

Once the script is finished, add what will make the tooltips appear for users. You can achieve this by inserting a custom attribute into any element you wish to have a tooltip near.

Steps:

1.Pick the element you want the tooltip to appear in Webflow, like text, an icon, a button or an image.

2.On the Element Settings panel (accessible with D shortcut), find the section called Custom Attributes.

3.Go to Add Custom Attribute on the menu.

4.Enter this information:

  • Name: data-tooltip

  • The task here is to insert the text you’d like to show. A tip such as this is useful.

3. Publish & Test

After installing the script and configuring tooltip attributes, you can watch your tooltips appear.

Steps:

1.At the top right of Webflow, press the Publish button to make your site public.

2.Pick where you want your site to be visible online: the staging domain or your own domain.

3.When finished, check the live site in your web browser.

Hover over any part of the interface that has data-tooltip set in its HTML. Once you type, you will notice a small blue tooltip above the selected element.

When things aren’t going well:

  • Ensure that the script has been added to the Before </body> part of your code.

  • All your elements should have the data-tooltip attribute and a value.

  • Refresh the website on your browser or use incognito mode so you don’t get cache issues.

Conclusion

By including tooltips in Webflow, you give advice or instructions without disrupting your design. You can quickly make tooltips with a little script and a basic custom attribute, making links on your site easier for anyone to use. Using tooltips, you can clearly label items, guide users through forms and explain additional steps on any modern website.

Having seen the tooltip function, consider making it in line with your brand theme and play around with further features whenever you like.

FAQ'S

How To Add Simple Tooltips In Webflow

You can easily use Webflow’s default features to make tooltips. However, working with a simple script changes things for the better and only requires setting up once for several tooltips across your site.

Will the tooltips work on mobile devices?

The touchscreen is using hover as the default script which isn’t the best option. You are able to change the script to detect taps or create mobile-friendly tooltips using Webflow interactions.

Can I customize the tooltip style?

Yes. You have the option to apply custom CSS to tooltips or add a custom class in Webflow and use the code editor or style features built in.

Are tooltips accessible for screen readers?

It is not possible by default. Should accessibility matter, you can either use aria-label or native title attributes or try some advanced accessible tooltip libraries.

Can I use images or HTML inside tooltips?

You can use the method presented here only for typing plain text. When you have images or more involved content, you should either use a custom tooltip component or build your own using Webflow interactions.

We make websites that bring joy and meet your goals.

We create digital experiences that not only capture the users but also empower businesses in a highly competitive world. We are dedicated towards developing creative solutions that will easily fuse creativity with functionality, with long-lasting effects.

Get in touch
Schedule a call with Webflow Certified Partner
Schedule Consultation
icon tick
Link Copied!
cross icon