Skip to content
Related Articles
Open in App
Not now

Related Articles

Semantic-UI Menu Active State

Improve Article
Save Article
Like Article
  • Last Updated : 29 Mar, 2022
Improve Article
Save Article
Like Article

Semantic UI open-source framework gives icons or glyphs that are used to show pictures related to some elements using CSS and jQuery that is used to create great user interfaces. It is a development framework used to create beautiful and responsive layouts.

Semantic UI Menu is a group of elements that displays different navigation actions. We can navigate to different pages of the website. A menu can be a combination of links, a search bar, and dropdowns.

Semantic UI Menu Active State specifies that the item is clicked and active. The button appears in darker contrast to other buttons or links.

Semantic UI Menu Active State Class:

  • active: Adding this class to the item, the item becomes active.

Syntax: Add the class active to the item as follows:

<div class="link active item">
     Machine Learning
</div>

Example: In the following example, if the user clicks on any link, the item becomes active, and if clicked again, it becomes inactive.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" href=
    </script>
</head>
  
<body>
    <div class="ui container">
        <center>
            <div class="ui header green">
                <h1>GeeksforGeeks</h1>
            </div>
            <strong>Semantic UI Menu Active State</strong>
            <br />
            <br />
        </center>
  
        <div class="ui compact menu">
            <div class="header item">
                GeeksforGeeks
            </div>
            <a class="item" href=
                target="_blank">
                Data Structures
            </a>
            <a class="item" href=
                target="_blank">
                Algorithms
            </a>
            <div class="link item">
                Machine Learning
            </div>
        </div>
    </div>
    <script>
        $('.item').click(function() {
            $(this).toggleClass('active')
        })
    </script>
</body>
  
</html>

Output:

Reference: https://semantic-ui.com/collections/menu.html#active


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!