Skip to main content

Tooltip Ready

Tooltips are floating labels that briefly explain the function of a user interface element. They can be triggered when user clicks or navigates to it via keyboard.

Please keep in mind that when the screen width is under 768px this component should always be positioned on the right side of the screen as it’s going to open towards left.

Examples #

Open in new window
<div style="padding-top: 170px; margin: 0 auto; max-width: 100px">
<duet-tooltip active>
Hello, I’m a tooltip! To close me you can hit ESC key, click the close button, or click the X button.
</duet-tooltip>
</div>
Open in new window
<div style="margin: 260px 0 0 20px; width: 100%; min-height: 100px">
<duet-tooltip active label="Click me to open a tooltip">
Hello, I’m a tooltip! To close me you can hit ESC key, click the close button, or click the X button.
</duet-tooltip>
</div>
Open in new window
<div style="margin: 40px auto 0; width: 60%; min-height: 400px">
<duet-input
label="Katuosoite"
placeholder="Kadunnimi 1 A 2"
tooltip="Hello, I’m a tooltip! To close me, you can click outside of the tooltip, hit ESC key or click the X button."
required
expand
>
</duet-input>
</div>
Open in new window
<div style="padding-top: 170px; margin: 0 auto; max-width: 100px">
<duet-tooltip breakpoint="large" active>
Hello, I’m a tooltip! To close me you can hit ESC key, click the close button, or click the X button.
</duet-tooltip>
</div>
Open in new window
<div style="padding-top: 170px; margin: 0 auto; max-width: 100px">
<duet-tooltip direction="right" active>
Hello, I’m a tooltip! To close me you can hit ESC key, click the close button, or click the X button.
</duet-tooltip>
</div>
Open in new window
<div style="padding-top: 170px; margin: 0 auto; max-width: 100px">
<duet-tooltip direction="left" active>
Hello, I’m a tooltip! To close me you can hit ESC key, click the close button, or click the X button.
</duet-tooltip>
</div>

Properties #

Property Attribute Description Type Default
accessibleAboutLabel accessible-about-label String to add after the accessibleLabel to give more context to the tooltip. Preposition "about" is added between the strings. In Finnish, the preposition is "aiheesta" and in Swedish "om". string undefined
accessibleCloseLabel accessible-close-label Adds accessible label for the close icon that is only shown for screen readers. This property is always required to create an accessibly interface! string getLocaleString( this.accessibleCloseLabelDefault, this.language )
accessibleCloseLabelDefault accessible-close-label-default Default language strings for the accessibleCloseLabel DuetLangObject | string { fi: "Sulje lisätiedot", en: "Close details", sv: "Stäng tilläggsuppgifter", }
accessibleLabel accessible-label Adds accessible label for the info icon that is only shown for screen readers. This property is always required to create an accessible interface! string getLocaleString(this.accessibleLabelDefault, this.language)
accessibleLabelDefault accessible-label-default Default language strings for the accessibleLabel DuetLangObject | string { fi: "Näytä lisätietoja", en: "Show more information", sv: "Visa mer tilläggsuppgifter", }
active active Toggle whether the tooltip is initially visible or not. This property should not be used in production in most cases. boolean false
breakpoint breakpoint Adjust the responsive breakpoint where tooltip starts opening towards left. "large" | "medium" "medium"
direction direction With direction setting you can force the tooltip to always open towards left or right instead of automatically determining the direction. "auto" | "left" | "right" "auto"
label label Label of the tooltip. If used, replaces the accessibleLabel option. string ""
language language [DEPRECATED] this is now handled via the html lang tag, and is no longer used - kept to avoid breaking changes and ease unit testing

The currently active language. This setting changes the accessible labels to match the chosen language.
"en" | "fi" | "sv" getLanguage()
positionHorizontal position-horizontal Adjust the horizontal positioning of the tooltip toggle in pixels. Can be a negative value as well. E.g. "-13px". string "0"
positionVertical position-vertical Adjust the vertical positioning of the tooltip toggle in pixels. Can be a negative value as well. E.g. "-13px". string "0"
theme theme Theme of the tooltip. "" | "default" | "turva" ""

Usage #

This section includes guidelines for designers and developers about the usage of this component in different contexts.

When to use #

  • When you need to provide an explanation for an element.
  • To add a floating label that briefly explains the function of a user interface element.

When not to use #

  • For communicating critical information, like errors. Use alert component instead.
  • When you need to include links or actions.
  • When you have a long explanation.

Accessibility #

This component has been validated to meet the WCAG 2.1 AA accessibility guidelines. You can find additional information regarding accessibility of this component below.


Integration

For integration, event and theming guidelines, please see Using Components. This documentation explains how to implement and use Duet’s components across different technologies like Angular, React or Vanilla JavaScript.

Integration guidelines


Tutorials

Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:

Tutorials

Building Layouts

Tutorials

Using CLI Tools

Tutorials

Creating Custom Patterns

Tutorials

Server Side Rendering

Tutorials

Sharing Prototypes

Tutorials

Usage With Markdown


Troubleshooting

If you experience any issues while using a component, please head over to the Support page for more guidelines and help.