Open In App

Primer CSS Tooltip Alignment

Last Updated : 08 Apr, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by Object-Oriented CSS principles, functional CSS, and BEM architecture. It is highly reusable and flexible. It is created with GitHub’s design system.

The Tooltip Alignment can be used to align the tooltip to the left or right using the different alignment classes.

Primer CSS Tooltip Alignment Class:

  • tooltipped-align-right-1: This class is used on the tooltipped container to align the tooltip to the right of the element with an arrow more intended.
  • tooltipped-align-right-2: This class is used on the tooltipped container to align the tooltip to the right of the element with an arrow less intended.
  • tooltipped-align-left-1: This class is used on the tooltipped container to align the tooltip to the left of the element with an arrow more intended.
  • tooltipped-align-left-2: This class is used on the tooltipped container to align the tooltip to the left of the element with an arrow less intended.

Syntax:

<element class="tooltipped tooltipped-nw tooltipped-align-right-1 border">
    ...
</element>

Example1: This example illustrates the implementation of the Tooltip Alignment classes in Primer CSS.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
    <title>
        Tooltip Alignment - Primer CSS
    </title>
    <link href=
"https://unpkg.com/@primer/css@^16.0.0/dist/primer.css" 
        rel="stylesheet" />
</head>
  
<body>
    <div class="text-center">
        <h2>GeeksforGeeks</h2>
        <h4>Primer CSS - Tooltip Alignment</h4>
    </div>
    <div class="d-flex flex-justify-center mt-5 flex-wrap">
        <button type="button" class="tooltipped 
            tooltipped-nw tooltipped-align-right-1 m-2 p-2 border"
            aria-label="Tooltipped NW and aligned right.">
            Right Aligned Tooltip 1
        </button>
  
        <button type="button" class="tooltipped tooltipped-nw 
            tooltipped-align-right-2 m-2 p-2 border"
            aria-label="Tooltipped NW and aligned right.">
            Right Aligned Tooltip 2
        </button>
  
        <button type="button" class="tooltipped tooltipped-ne 
            tooltipped-align-left-1 m-2 p-2 border"
            aria-label="Tooltipped NW and aligned left.">
            Left Aligned Tooltip 1
        </button>
  
        <button type="button" class="tooltipped tooltipped-ne 
            tooltipped-align-left-2 m-2 p-2 border"
            aria-label="Tooltipped NW and aligned left.">
            Left Aligned Tooltip 2
        </button>
    </div>
</body>
  
</html>


Output:

Primer CSS Tooltip Alignment

Example 2: The below example displays the alignment of the Primer CSS tooltip with different elements.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
    <title>
        Tooltip Alignment - Primer CSS
    </title>
    <link href=
"https://unpkg.com/@primer/css@^16.0.0/dist/primer.css" 
        rel="stylesheet" />
</head>
  
<body>
    <div class="text-center">
        <h2>GeeksforGeeks</h2>
        <h4>
            Primer CSS - Tooltip Alignment 
            with different elements
        </h4>
    </div>
  
    <div class="d-flex flex-justify-center mt-5 flex-wrap">
        <button type="button"
            class="tooltipped tooltipped-nw 
                tooltippd-align-right-1 tooltipped-no-delay 
                m-2 p-2 border"
            aria-label="Right Aligned Tooltip on a button.">
            Tooltip on a button
        </button>
        <p class="tooltipped tooltipped-nw 
            tooltipped-align-right-2 m-2 p-2"
            aria-label="Right Aligned Tooltip on a paragraph.">
            Tooltip on a paragraph
        </p>
  
        <h5 class="tooltipped tooltipped-ne 
            tooltipped-align-left-1 m-2 p-2"
            aria-label="Left Aligned Tooltip on a heading.">
            Tooltip on a heading
        </h5>
    </div>
</body>
  
</html>


Output:

 

Reference: https://primer.style/css/components/tooltips#tooltip-alignment



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads