Open In App

Semantic-UI | Popup

Last Updated : 20 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website look more amazing. It uses a class to add CSS to the elements.

Pop is used to display some content on the top of the page.

Syntax: jQuery Code

$('.button').popup();

Example 1: This example displaying a popup message on mouse move over.




<!DOCTYPE html>
<html>
  
<head>
    <title>Semantic UI</title>
  
    <link href=
        rel="stylesheet" />
  
        integrity=
"sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" 
        crossorigin="anonymous">
    </script>
  
    <script src=
    </script>
</head>
  
<body>
    <div style="margin-top: 20px" class="ui container">
        <div class="ui button" data-content=
            "You are learning Semantic-ui popup">
            Hover Me
        </div>
    </div>
  
    <script>
        $('.button').popup();
    </script>
</body>
  
</html>


Output:

If we don’t specify the property in the popup() function then it popup on hover.

Example 2:

This example displaying a Popup Menu.

jQuery code:

$('.menu .browse').popup({
   hoverable: true,
});

Hoverable property is set to true to hover over the popup menu. If we don’t use this property, it will be false and won’t be able to hover over the popup menu.

Complete Code:




<!DOCTYPE html>
<html>
  
<head>
    <title>Semantic UI</title>
    <link href=
            rel="stylesheet" />
  
        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
        crossorigin="anonymous">
    </script>
  
    <script src=
    </script>
</head>
  
<body>
    <div style="margin-top: 20px" class="ui container">
        <div class="ui menu">
            <a class="browse item">
                Geeksforgeeks
                <i class="dropdown icon"></i>
            </a>
            <div class="ui fluid popup bottom left transition hidden"
                style="top: 554.6px; left: 1px; bottom: auto; 
                                right: auto; width: 840.2px;">
                <div class="ui four column relaxed divided grid">
                    <div class="column">
                        <h4 class="ui header">Data Structure</h4>
                        <div class="ui link list">
                            <a class="item">Array</a>
                            <a class="item">LinkList</a>
                            <a class="item">Tree</a>
                        </div>
                    </div>
                    <div class="column">
                        <h4 class="ui header">Web</h4>
                        <div class="ui link list">
                            <a class="item">Angular</a>
                            <a class="item">React</a>
                            <a class="item">Node</a>
                        </div>
                    </div>
                    <div class="column">
                        <h4 class="ui header">Language</h4>
                        <div class="ui link list">
                            <a class="item">C++</a>
                            <a class="item">Python</a>
                            <a class="item">JavaScript</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
  
    <script>
        $('.menu .browse').popup();
    </script>
</body>
  
</html>


Output:

Example 3:

This example displaying a Popup message after clicking the button.

jQuery Code:

$('.button').popup({
   on: 'click'
});

Complete Code:




<!DOCTYPE html>
<html>
  
<head>
    <title>Semantic UI</title>
  
    <link href=
    rel="stylesheet" />
  
        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
        crossorigin="anonymous">
    </script>
      
    <script src=
    </script>
</head>
  
<body>
    <div style="margin-top: 20px" class="ui container">
        <div class="ui button" data-content=
            "You are learning Semantic-ui popup">
            Click Me
        </div>
    </div>
  
    <script>
        $('.button').popup({
            on: 'click'
        });
    </script>
</body>
  
</html>


Output:

Example 4:

This example displaying the Popup message in Input Field.

jQuery Code:

$('input').popup({
   on: 'focus'
});

on: 'focus' is used because we only want to show popup when user focus on that input field.

Complete Code:




<!DOCTYPE html>
<html>
  
<head>
    <title>Semantic UI</title>
    <link href=
        rel="stylesheet" />
  
        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
        crossorigin="anonymous">
    </script>
      
    <script src=
    </script>
</head>
  
<body>
    <div style="margin-top: 20px" class="ui container">
        <div class="ui icon input">
            <input type="text" placeholder="Enter Email"
                data-content=
"Enter the email of person whose account you want to search" />
            <i class="search icon"></i>
        </div>
    </div>
      
    <script>
        $('input').popup({
            on: 'focus'
        });
    </script>
</body>
  
</html>


Output:

Example 5:

Target Element – Show popup somewhere else.

jQuery Code:

$('.button').popup({
  position : 'right center',
  target   : '.image',
  title    : 'Geeksforgeeks',
  content  : 'A Computer Science Portal'
});
  • position: Where you want to show the popup.
  • target: On which element you want to show the popup when hovered over .button.
  • title and content: It is showing in a popup.

Complete Code:




<!DOCTYPE html>
<html>
  
<head>
    <title>Semantic UI</title>
    <link href=
        rel="stylesheet" />
  
        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
        crossorigin="anonymous">
    </script>
      
    <script src=
    </script>
</head>
  
<body>
    <div style="margin-top: 20px" class="ui container">
        <div class="ui primary button">Hover Me</div>
        For more detail of Picture
        <div class="ui divider"></div>
        <img class="medium ui image" src=
    </div>
      
    <script>
        $('.button').popup({
            position: 'right center',
            target: '.image',
            title: 'Geeksforgeeks',
            content: 'A Computer Science Portal'
        });
    </script>
</body>
  
</html>


Output:



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

Similar Reads