Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • BS5 Tutorial
  • BS5 Interview Questions
  • BS5 Layout
  • BS5 Content
  • BS5 Components
  • BS5 Helpers
  • BS5 Utilities
  • BS4 Tutorial
  • BS Tutorial
  • Bootstrap Cheatsheet
  • Tailwind
  • CSS Frameworks
  • HTML Formatter
Open In App
Next Article:
Bootstrap 5 Popovers Methods
Next article icon

Bootstrap 5 Popovers Using function with popperConfig Options

Last Updated : 09 Jan, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Bootstrap 5 Popover is a feature of Bootstrap that allow you to display a small popup over the element when an element is clicked or hovered over.

Bootstrap 5 Popovers Using function with popperConfig Options: Popover popperConfig option is used to customize the behavior of the popover. The popperConfig option is an object that contains a set of options and modifiers that control the placement and behavior of the popover.

Syntax :

var popover = new bootstrap.Popover(element, {      popperConfig: function (defaultBsPopperConfig) {      }  })

Example 1: In this example, we place the popover on the right of element by using the popperConfig option.

HTML
<!DOCTYPE html> <html> <head>            <link rel="stylesheet" href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">     <script src= "https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js">     </script>     <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js">     </script>     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js">     </script> </head> <body class="text-center">     <br>     <br>     <h1 class="text-success">GeeksforGeeks</h1>     <h3>Popovers with popperConfig Options</h3>     <button id="btn-popover" type="button" class="btn btn-primary"              data-toggle="popover" title="Popover Title"              data-content="Popover content">             Toggle Popover     </button>      <!-- Initialize the popover with popperConfig options -->     <script type="text/javascript">         $(document).ready(function() {             $('#btn-popover').popover({               popperConfig: {                 placement: 'right',                 modifiers: {                     preventOverflow: {                         enabled: true,                         boundariesElement: 'window'                     }                 }               }             });         });     </script> </body> </html> 

Output:

Bootstrap 5 Popovers Using function with popperConfig Options
Bootstrap 5 Popovers Using function with popperConfig Options

Example 2: In this example, we will pass various popover options using the popperConfig option.

HTML
<!DOCTYPE html> <html> <head>            <link rel="stylesheet" href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">     <script src= "https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js">     </script>     <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js">     </script>     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js">     </script> </head> <body class="text-center">     <br>     <br>     <h1 class="text-success">GeeksforGeeks</h1>     <h3>Popovers with popperConfig Options</h3>     <button id="btn-popover" type="button" class="btn btn-primary"              data-toggle="popover" title="Popover Title"              data-content="Popover content">             Toggle Popover     </button>      <!-- Initialize the popover with popperConfig options -->     <script type="text/javascript">         $(document).ready(function() {             $('#btn-popover').popover({                popperConfig: {                     placement: 'bottom',                     modifiers: {                          delay: {                             delay: { "show": 500, "hide": 100 }                         },                         offset: {                             offset: '0,10'                         },                         preventOverflow: {                             boundariesElement: 'viewport'                         },                         flip: {                             behavior: 'flip'                         },                         arrow: {                             element: '.arrow'                         }                     },                     eventsEnabled: true,                     positionFixed: false                 }             });         });     </script>  </body> </html> 

Output :

Bootstrap 5 Popovers Using function with popperConfig Options
Bootstrap 5 Popovers Using function with popperConfig Options

Reference: https://getbootstrap.com/docs/5.0/components/popovers/#using-function-with-popperconfig


Next Article
Bootstrap 5 Popovers Methods

J

jayadeepreddypeddireddy
Improve
Article Tags :
  • Technical Scripter
  • Web Technologies
  • Bootstrap
  • Technical Scripter 2022
  • Bootstrap-5

Similar Reads

  • Bootstrap 5 Popovers
    Bootstrap 5 Popovers Provides directional placement options (top, bottom, left, right), dismiss on click, and support for disabled elements. Styled with Sass, they feature various methods, options, and events for dynamic interaction and customization. Bootstrap 5 Popovers: AspectDescriptionFour dire
    2 min read
  • Bootstrap 5 Popovers Four directions
    The popover is a bootstrap component used to mainly add additional information to a website. It is a pop-up box that appears when the user clicks on an element. Using bootstrap attributes, It can be aligned in any of the four directions left, top, right, and bottom. Bootstrap 5 Popovers Four directi
    3 min read
  • Bootstrap 5 Popovers Dismiss on next click
    The popover is an attribute of bootstrap used to make the website look more effective. Popovers are mainly used to display additional information and are displayed with the click of the mouse pointer on a button. Popovers can be dismissed on the user’s next click of a different element than the togg
    2 min read
  • Bootstrap 5 Popovers Disabled Elements
    Bootstrap 5 Popovers are an amazing way to show some quick information when hovered over a button or anchor or span tag. In popovers, there exists an option to disable the popover element. Disabling the element essentially means that the popover won't work anymore. The disabling is mainly done using
    2 min read
  • Bootstrap 5 Popovers SASS
    Bootstrap 5 Popovers SASS has a set of variables that are usually set to a default value but it can be changed accordingly to customize the Popover. SASS variable of Popovers: SASS variables and their default values: $popover-font-size ($font-size-sm): This variable is used to change the font size o
    5 min read
  • Bootstrap 5 Popovers Usage
    Bootstrap 5 popover is similar to the tooltips which have a pop-up box that appears when we click the element. We can insert the content into the popover box by using the attribute called "data-bs-content". We can also include interactive controls. Bootstrap 5 Popovers Usage Events: Options: Options
    2 min read
  • Bootstrap 5 Popovers Options
    Bootstrap 5 Popovers are small overlays that can be displayed on top of content to provide additional context or action options. Popover option are used to perform the specific function on the element. Options can be passed through the data attributes or java script. To pass the data attributes we S
    3 min read
  • Bootstrap 5 Popovers Using function with popperConfig Options
    Bootstrap 5 Popover is a feature of Bootstrap that allow you to display a small popup over the element when an element is clicked or hovered over. Bootstrap 5 Popovers Using function with popperConfig Options: Popover popperConfig option is used to customize the behavior of the popover. The popperCo
    2 min read
  • Bootstrap 5 Popovers Methods
    Bootstrap 5 Popovers methods enable manual control over the visibility of popover elements, allowing users to show or hide them as needed, enhancing interactivity and customization options within web applications. Bootstrap 5 Popovers Methods: MethodDescriptiontoggleToggles the visibility of a popov
    2 min read
  • Bootstrap 5 Popovers show() Method
    Bootstrap 5 Popovers show() method is used to open the popover manually. It will show the popover before the actual shown.bs.popover event occurs. Syntax: popover.show() Return value: This method will manually trigger the element’s popover to be displayed. Example 1: In this example, we will learn a
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences