Semantic-UI | Popup - GeeksforGeeks

20 May, 2020
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="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"        rel="stylesheet" />      <script src="https://code.jquery.com/jquery-3.1.1.min.js"         integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="         crossorigin="anonymous">    </script>      <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js">    </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="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"            rel="stylesheet" />      <script src="https://code.jquery.com/jquery-3.1.1.min.js"        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="        crossorigin="anonymous">    </script>      <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js">    </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="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"    rel="stylesheet" />      <script src="https://code.jquery.com/jquery-3.1.1.min.js"        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="        crossorigin="anonymous">    </script>          <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js">    </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="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"        rel="stylesheet" />      <script src="https://code.jquery.com/jquery-3.1.1.min.js"        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="        crossorigin="anonymous">    </script>          <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js">    </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="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"        rel="stylesheet" />      <script src="https://code.jquery.com/jquery-3.1.1.min.js"        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="        crossorigin="anonymous">    </script>          <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js">    </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="https://media.geeksforgeeks.org/wp-content/uploads/20200511124031/image30.png">    </div>          <script>        $('.button').popup({            position: 'right center',            target: '.image',            title: 'Geeksforgeeks',            content: 'A Computer Science Portal'        });    </script></body>  </html>
Output:
Semantic-UI
CSS
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to apply style to parent if it has child with CSS?
How to position a div at the bottom of its container using CSS?
Types of CSS (Cascading Style Sheet)
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
How to Dynamically Add/Remove Table Rows using jQuery ?