Open In App

Primer CSS Header

Primer CSS is a free open-source CSS framework that is built upon a GitHub design system to provide support to the broad spectrum of GitHub websites. It creates 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 a highly reusable model.

In this article, we will learn about the Header component of the Primer CSS. One such component of the Primer CSS is the Header component. The header component as the name suggests helps us to create a header for our website. Now, what is a header? A header is a component that has all the items vertically aligned. In Primer CSS, we can create a header by adding the “.header” class to the element, and also we can create the items by adding the “.header-item” class to the element.



Primer CSS Header Components: 

Syntax:



<div class="Header">
    <div class="Header-item">
        ...
    </div>
    <div class="Header-item">
        ...
    </div>
    ...
</div>

Example 1: We have created a simple header with text and input fields.




<!DOCTYPE html>
<html>
<head>
    <title> Primer CSS Toast animation in </title>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css"/>
</head>
<body>
    <div class="Header">
        <!-- Text item -->
        <div class="Header-item">
            GeeksforGeeks
        </div>
        <div class="Header-item">
            Articles
        </div>
        <div class="Header-item">
            Practice QS
        </div>
        <!-- Form item  -->
        <div class="Header-item">
            <input class="form-control Header-input"
                type="text"/>
        </div>
        <!-- Image item  -->
        <div class="Header-item">
            <img class="avatar" height="20"
                alt="@octocat"
                src="https://github.com/octocat.png"
                width="20">
        </div>
    </div>
    <div>
        <h2>GeeksforGeeks</h2>
        <h3>Primer CSS Header </h3>
    </div>
</body>
</html>

Output:

 

Example 2: We have created a header with hyperlinks to the items.




<!DOCTYPE html>
<html>
<head>
    <title> Primer CSS Toast animation in </title>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css"/>
</head>
<body>
    <div class="Header">
        <!-- Text item -->
        <div class="Header-item">
            <a href="#" class="Header-link">
                GeeksforGeeks
            </a>
        </div>
        <div class="Header-item">
            <a href="/articles.html" class="Header-link">
                Articles
            </a>
        </div>
        <div class="Header-item">
            <a href="/DSA.html" class="Header-link">
                DSA Q/s
            </a>
        </div>
        <!-- Form item  -->
        <div class="Header-item--full">
            <input class="form-control Header-input"
                type="text"/>
        </div>
        <!-- Image item  -->
        <div class="Header-item">
            <img class="avatar" height="20" alt="@octocat"
                src="https://github.com/octocat.png"
                    width="20">
        </div>
    </div>
    <div>
        <h2>GeeksforGeeks</h2>
    </div>
</body>
</html>

Output:

 

Reference: https://primer.style/css/components/header


Article Tags :