Open In App

Primer CSS Toasts Toast Position

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 Toast is used to display live feedback to the user. The Position is used to specify the toast position by adding the utility classes on a wrapper element of the viewport.

Primer CSS Toast Position Class:

  • *position: It is used to specify the toast position. For eg., position-fixed bottom-0 right-0.

Syntax:

<div class="*position">
  <div class="Toast">
    <span class="Toast-icon">
           Content
    </span>
    <span class="Toast-content">
          Content
    </span>
  </div>
</div>

Example 1: The following code demonstrates the Primer CSS Toast Position at the bottom right position.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title> Primer CSS Toast Position </title>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css" /> 
</head>
  
<body>
    <div class="text-center">
        <h1 class="color-fg-success"> GeeksforGeeks </h1>
        <h3> Primer CSS Toast Position </h3
    </div>
    <div class="position-fixed bottom-1 right-2">
        <div class="Toast">
            <span class="Toast-icon">
                <svg class="octicon" 
                     viewBox="0 0 15 15" 
                     width="25" 
                     height="25">
                  <path d="M13.78 4.22a.75.75 0 010 1.06l-7.25 
                      7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 
                      011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z">
                  </path>
                </svg>
          </span
          <span class="Toast-content"
                GeeksforGeeks- Bottom Right 
          </span>
        </div>
    </div>
</body>
</html>


Output:

Primer CSS Toast Position at the bottom right position

Example 2: This example demonstrates the Primer CSS Toast Position at the top-left position.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>Primer CSS Toast Position</title>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css" /> 
</head>
  
<body>
    <div class="text-center">
        <h1 class="color-fg-success">GeeksforGeeks</h1>
        <h3>Primer CSS Toast Position</h3>
    </div>
    <div class="position-fixed top-0 left-0">
        <div class="Toast"
            <span class="Toast-icon">
              <svg class="octicon" 
                   viewBox="0 0 15 15" 
                   width="25" 
                   height="25">
                <path
                      d="M13.78 4.22a.75.75 0 010 1.06l-7.25 
                    7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 
                    011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z">
                </path>
              </svg>
            </span>
            <span class="Toast-content"
              GeeksforGeeks- Top left 
            </span>
        </div>
    </div>
</body>
</html>


Output:

Primer CSS Toast Position at the top left position

Reference: https://primer.style/css/components/toasts#toast-position



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

Similar Reads