• Stars
    star
    1,258
  • Rank 35,881 (Top 0.8 %)
  • Language
    HTML
  • License
    MIT License
  • Created over 11 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An unofficial Bootstrap plugin to enable Bootstrap dropdowns to activate on hover and provide a nice user experience.

Bootstrap Hover Dropdown Plugin

Join the chat at https://gitter.im/CWSpear/bootstrap-hover-dropdown

Current Version

Name Change

Twitter Bootstrap is now just Bootstrap, and I've renamed this repo, renamed the files and change all references from Twitter Bootstrap to just Bootstrap in the docs/example to reflect that.

No actual code changed, so I am keeping the current version (2.0.1 at the time of this writing), but be aware of the lack of twitter- from the beginning of the JS files and how that might affect you.

Sorry for any inconvenience!

Updated for Bootstrap 3

I updated the demo with Bootstrap 3, as well as removed code associated to submenus (not supported in Bootstrap 3) and touch devices (just make sure you have data-toggle="dropdown" to let Mobile do its thing and my plugin won't interfere).

Introduction

A simple plugin to enable Bootstrap dropdowns to activate on hover and provide a nice user experience.

The dropdowns are dismissed after a configurable delay. This fixes an issue that can instantly close your nav because of a 1px gap between the button/nav item that activated the dropdown and the actual dropdown. It is also generally a better user experience, as users are not punished by going 1 pixel outside of the dropdown, which would instantly close the nav without a delay.

Note: The HTML markup is the same as with any other Bootstrap dropdown. This will not interfere with Bootstrap's default activate-on-click method (i.e. this plugin combined with Bootstrap's default behavior work well to support both the ideal experience on desktop and mobile).

Installation

You can simply download and extract the package downloaded from GitHub. Alternatively, you can download the files via Bower (a JavaScript package management system):

bower install bootstrap-hover-dropdown

which will also automatically install Bootstrap and jQuery if needed.

Once you have the files downloaded, link to the files in your code after you include the main Bootstrap JS file(s):

<!-- script order matters! -->
<script src="/path/to/jquery.min.js"></script>
<script src="/path/to/bootstrap.min.js"></script>
<script src="/path/to/bootstrap-hover-dropdown.min.js"></script>

Usage

Just like in Bootstrap you can activate it without any JavaScript, just by adding a data-attribute, you can make it automatically work.

Add data-hover="dropdown" in addition (or in place of) Bootstrap's data-toggle="dropdown".

You can set options via data-attributes, too, via data-delay and data-close-others. Here's an example of markup:

<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="false">
        Account <b class="caret"></b>
    </a>
    <ul class="dropdown-menu">
        <li><a tabindex="-1" href="#">My Account</a></li>
        <li class="divider"></li>
        <li><a tabindex="-1" href="#">Change Email</a></li>
        <li><a tabindex="-1" href="#">Change Password</a></li>
        <li class="divider"></li>
        <li><a tabindex="-1" href="#">Logout</a></li>
    </ul>
</li>

Alternatively, you can initialize via JavaScript:

$('.dropdown-toggle').dropdownHover(options);

This also works with submenus without any other configuring since Bootstrap already supports this feature. Just use the markup like you were using before. Only the top level anchor tag needs any special markup for my plugin to work (see demo for proper markup).

Options

  • delay: (optional) The delay in miliseconds. This is the time to wait before closing a dropdown when the mouse is no longer over the dropdown or the button/nav item that activated it. Defaults to 500.
  • instantlyCloseOthers: (optional) A boolean value that when true, will instantly close all other dropdowns matched by the selector used when you activate a new navigation. This is nice for when you have dropdowns close together that may overlap. Default is true.
  • hoverDelay: (optional) A delay before opening in miliseconds. Some people argue this improves user experience as it decreases the number of accidental menu openings. Defaults to 0.

Demo

You can view a demo for this plugin on my site: http://cameronspear.com/demos/bootstrap-hover-dropdown/

A Note on Choosing a Selector

This plugin purposedly lets you choose a selector (as opposed to apply this to everything with the class of .dropdown-toggle). This is so that you can selectively apply it where you want. Maybe you only want to use it for the main nav, and not have it activate for dropdown buttons in the main content. You can add a class to the item that normally gets .dropdown-toggle and use that class with this plugin to easily achieve that, or use a selector such as .main-nav .dropdown-toggle.

Important: Bootstrap relies on styles associated with the class .dropdown-toggle (for stuff like the caret color), and it is recommended you leave that class alone.

Changes/Bug Fixes

I'm a slacker and only started keeping track of changes/bug fixes starting in March of 2013.

  • 2015-12-01 [v2.2.1] Update README
  • 2015-12-01 [v2.2.0] New logic: don't do anything when the navbar is collapsed
  • 2015-02-07 [v2.1.3] Update version in JS files
  • 2015-02-07 [v2.1.2] Forgot to minify the last couple updates...
  • 2015-02-07 [v2.1.1] Merged another PR: browserify compatibility #100.
  • 2015-02-07 [v2.1.0] Merged a couple PRs: ARIA support #95 and hover delay support #99.
  • 2014-06-16 Added package to composer.
  • 2014-05-12 Fixed an issue where you could click a parent menu item to close it, but moving away from it would re-open the menu. Also cleaned up some code, removed some redundency.
  • 2014-01-27 Fixed an issue where chaining could break on mobile and cleaned up the the way the plugin triggered events. Also cleaned up the demo (fixed navbar appearance).
  • 2013-12-05 Change all references of Twitter Bootstrap to Bootstrap to reflect Bootstrap's name change.
  • 2013-11-09 Disable this plugin for devices that support touch. The plugin was causing issues with some mobile devices, and it's not necessary for them.
  • 2013-08-02 Add support for Bootstrap 3. For Bootstrap 2.x.x, use the bootstrap-2.x.x branch.
  • 2013-06-10 Always instantly close submenu siblings when opening a new one. Issue #19.
  • 2013-06-10 A fix for my last fix that would sometimes cause the correct item to not trigger when it should. Issue #18.
  • 2013-05-08 Fix issue where a sibling could open a drop down that wasn't theirs. Issue #18.
  • 2013-04-29 Added support for submenus: Submenus should now honor the delay option and way before closing. They do not abide by the instantlyCloseOthers option, as it's not really relevant.
  • 2013-04-19 Fixed an issue where the conditional rule to disable hover on mobile wasn't working if you included the script in the header.
  • 2013-04-03 Made it so if you're using the responsive CSS and in tablet/mobile view, disable the hover.
  • 2013-03-16 Fixed an issue where the options you passed in via the method call were completely ignored.

Contributions

Thanks to all of you who have contributed to this project, whether by code or by filing an issue to help improve it. But of course, especially the ones that contribute code =)

A special thanks to Mattia Larentis. He isn't in the contributor list, but he helped me with the idea for the data-attributes and doing the options via an object.

I will also issue a very special thanks in the README for help with setting up a testing suite!

Roadmap

As this plugin, in its simplicity, is pretty much exactly what I intend it to be, I don't plan to implement any new features. One exception: I would like to tweak it so that when you're in a submenu, it doesn't instantly close when you hover outside of it. Update: I added this in late April 2013.

If you have ideas for a new feature or something along those lines, you're welcome to share them with me, but I am not likely to implement it/merge your pull without a very compelling reason. You are absolutely free to create a fork and implement the feature yourself for your and others' use.

This, of course, does not speak for bugs. If you have a bug, please bring it to my attention, and I will try and fix it. Note that 93.7% of people's issues are caused by incorrect markup, so please double check that first.

Me

Follow me on Twitter: @CWSpear or check out my blog.

More Repositories

1

mdb-ui-kit

Bootstrap 5 & Material Design UI KIT
SCSS
24,004
star
2

Tailwind-Elements

𝙃𝙪𝙜𝙚 collection of Tailwind components, sections and templates 😎
HTML
11,821
star
3

material-design-for-bootstrap

Important! A new UI Kit version for Bootstrap 5 is available. Access the latest free version via the link below.
JavaScript
9,415
star
4

bootstrap-templates

A collection for Bootstrap 5 templates.
3,069
star
5

adminlte-laravel

A Laravel 5 package that switchs default Laravel scaffolding/boilerplate to AdminLTE template and Pratt Landing Page with Bootstrap 3.0
PHP
1,817
star
6

mdb-react-ui-kit

React 17 & Bootstrap 5 & Material Design 2.0 UI KIT
TypeScript
1,331
star
7

mdb-angular-ui-kit

Angular 14 & Bootstrap 5 & Material Design 2.0 UI KIT
SCSS
1,098
star
8

bootstrap-toggle-buttons

Bootstrap-toggle-buttons has moved to https://github.com/nostalgiaz/bootstrap-switch
JavaScript
1,023
star
9

mdb-vue-ui-kit

Vue 3 & Bootstrap 5 & Material Design 2.0 UI KIT
SCSS
925
star
10

Black-Friday-2023

Black Friday & Cyber Monday Deals (UI Kits WordPress Plugins, CRMs, SEO, Courses, Books) for web developers, programmers, and software engineers.
785
star
11

Bootstarters

Free templates for Bootstrap 5
390
star
12

bootstrap-fluent-design

Fluent Design Theme for Bootstrap - inspired by Windows style and based on the latest Bootstrap 5.
HTML
322
star
13

perfect-scrollbar

Minimalistic but perfect custom scrollbar plugin. Get more free components with Material Design for Bootstrap UI Kit (link below)
JavaScript
301
star
14

Bootstrap-4-templates

A collection of Bootstrap 4 Templates - Material Design for Bootstrap. Important! New templates are available. Access the new templates via the link below:
JavaScript
230
star
15

Angular-Bootstrap-Boilerplate

Angular CRUD application starter with NgRx state management and Firebase backend
TypeScript
195
star
16

knowledge-base

A common repository for all resources, tutorials, and useful materials. Find more free web development learning resources via the link below
SCSS
146
star
17

Ecommerce-Template-Bootstrap

Ecommerce Template - Bootstrap 4 & Material Design. ATTENTION! New templates for the latest Bootstrap 5 are now also available. Access new free templates via the link below.
JavaScript
142
star
18

TW-Elements-React

TW Elements for React - 𝙃𝙪𝙜𝙚 collection of Tailwind + React components, sections and templates 😎
HTML
132
star
19

bootstrap-5-freecodecamp-source-code

Source code to freeCodeCamp course for beginners
JavaScript
116
star
20

Admin-Dashboard-Template-Angular-Bootstrap

Admin template for Material Design for Angular Bootstrap.
HTML
89
star
21

mdb4-vue-ui-kit

Vue Bootstrap with Material Design - Powerful and free UI KIT
SCSS
75
star
22

mdb4-react-ui-kit

React Bootstrap with Material Design - Powerful and free UI KIT
JavaScript
74
star
23

mdbsvelte

Svelte Bootstrap with Material Design
Svelte
69
star
24

mdb-webpack-starter

Webpack Starter for Material Design for Bootstrap UI Kit based on the latest Bootstrap 5.
JavaScript
60
star
25

bootstrap-material-design

Important! A new UI Kit version for the latest Bootstrap 5 is available. Access the latest version via the link below
CSS
57
star
26

mdb-cli

Command Line Interface for MDB (https://mdbootstrap.com/) - learn more about CLI via the link below
TypeScript
57
star
27

mdb-docs-and-content

Content of the mdbootstrap.com website
HTML
56
star
28

Landing-Page-Template-Bootstrap

Landing Page Template - Bootstrap 4 & Material Design. ATTENTION! New templates for the latest Bootstrap 5 are now also available. Access new free templates via the link below.
JavaScript
56
star
29

Admin-Dashboard-Template-Bootstrap

Admin Dashboard Template - Bootstrap 4 & Material Design. ATTENTION! New templates for the latest Bootstrap 5 are now also available. Access new free templates via the link below.
JavaScript
47
star
30

Saas-Template-Bootstrap

This is a Saas Template for Bootstrap 4 & Material Design. ATTENTION! New templates for the latest Bootstrap 5 are now also available. Access new free templates via the link below.
JavaScript
46
star
31

Blog-Template-Bootstrap

Blog Template - Bootstrap 4 & Material Design. ATTENTION! New templates for the latest Bootstrap 5 are now also available. Access new free templates via the link below.
JavaScript
45
star
32

Admin-Dashboard-Template-React-Bootstrap

Admin Dashboard template for React, Bootstrap & Material Design.
JavaScript
45
star
33

bootstrap-5-dark-theme

Dark mode / dark theme template. Built with the latest Bootstrap 5 & Material Design.
HTML
44
star
34

Admin-Dashboard-Template-Vue-Bootstrap

Admin Template for Material Design for Vue Bootstrap.
Vue
42
star
35

Portfolio-Template-Bootstrap

Portfolio Template - Bootstrap 4 & Material Design. ATTENTION! New templates for the latest Bootstrap 5 are now also available. Access new free templates via the link below.
JavaScript
35
star
36

awesome-mdbootstrap

A curated list of awesome things related to MDBootstrap
34
star
37

Enhanced-Bootstrap-Modals

Collection of Enhanced Modals for Twitter Bootstrap
CSS
33
star
38

Bootstrap-5-Crash-Course-in-1.5H

These are lesson files for our 1,5h crash course on Bootstrap 5
JavaScript
30
star
39

Bootstrap-5-Landing-Page-Tutorial

This repository contains a source code to Bootstrap 5 Landing Page tutorial video. Access more Web Development tutorials via the link below
JavaScript
30
star
40

bootstrap-login-form

Responsive Login form built with Bootstrap 5. Lot of templates of signup forms and predefined form pages - various design, styles and functionalities.
JavaScript
27
star
41

Bootstrap-tutorial-for-beginners

Learn the main features of the most powerful mobile framework.
JavaScript
21
star
42

bootstrap-5-admin-template

Template for admin dashboards, control panels, reports, and others. Built with the latest Bootstrap 5 & Material Design.
JavaScript
20
star
43

mdb4-angular-ui-kit

Angular Bootstrap with Material Design - Powerful and free UI KIT
SCSS
18
star
44

Coming-Soon-Template-Bootstrap

Coming Soon Template - Bootstrap 4 & Material Design. ATTENTION! New templates for the latest Bootstrap 5 are now also available. Access new free templates via the link below.
JavaScript
18
star
45

bootstrap-chat

Responsive Chat built with Bootstrap 5. Many variants of the chat UI - mobile app, messages box, desktop widget and more.
JavaScript
17
star
46

black-friday-cyber-monday-2020

A list of Black Friday and Cyber Monday promotions and discounts for developers
16
star
47

mdb-easydata

Easily get data from any source and visualize it in an beautiful form
HTML
16
star
48

JS-tutorial-To-Do-List-App-for-beginners

This tutorial will teach you basics of JavaScript on the real app example. Access more Web Development tutorials via the link below
HTML
16
star
49

Magazine-Template-Bootstrap

Magazine Template - Bootstrap 4 & Material Design. ATTENTION! New templates for the latest Bootstrap 5 are now also available. Access new free templates via the link below.
JavaScript
15
star
50

jQuery-tutorial-for-beginners

jQuery tutorial for beginners. Access more Web Development tutorials via the link below
HTML
13
star
51

React-Tutorial-Agenda-App

This repo contains a lesson files for React development tutorial
JavaScript
12
star
52

MDB-Angular-PWA

MDB Angular Progressive Web App Tutorial application
HTML
12
star
53

bootstrap-5-full-carousel-cover-template

Make your website stand out with an image slider/carousel that takes up the entire viewport (fullscreen). Built with the latest Bootstrap 5 & Material Design.
JavaScript
12
star
54

MDB-VSCode-snippets

VS Code snippets for MDB
11
star
55

bootstrap-profiles

Responsive Profiles built with Bootstrap 5. Lots of templates such as card profile, user profile, profile form, with followers, avatars, comments, stats, social media and many more.
JavaScript
11
star
56

HTML-and-CSS-tutorial-for-beginners

Create your first website using HTML and CSS. Access even more Web Development tutorials via the link below:
HTML
11
star
57

mdb-angular-vscode-snippets

VS code snippets for MDB4 angular
10
star
58

MDB-5-Standard-snippets

Snippets for MDB 5 Standard
10
star
59

AJAX-tutorial-using-JS-and-jQuery-for-beginners

AJAX tutorial using JS and jQuery for beginners. Access more Web Development tutorials via the link below
HTML
10
star
60

Web-Developer-Roadmap

Roadmap to becoming a developer in 2022
9
star
61

bootstrap-shopping-carts

Responsive Shopping Carts built with Bootstrap 5. Multiple examples of various designs and functionalities. Ready to use pages and templates.
JavaScript
8
star
62

mdb-starter-webpack

JavaScript
7
star
63

HTML-Forms-and-validation-tutorial-for-beginners

This tutorial will teach you how to create and validate HTML forms. Access more Web Development tutorials via the link below
HTML
7
star
64

bootstrap-footer

The ultimate collection of responsive Footers built with the latest Bootstrap 5. Free for personal & commercial use. If you'd like to customize your Footers will find the documentation below.
7
star
65

Bootstrap-5-Tutorial-Portfolio

This repository is a result of a tutorial, link to the tutorial in a README. Access more Web Development tutorials via the link below
JavaScript
7
star
66

Vue-Tutorial-Agenda-App

Tutorial for an Agenda App built with VueJS. Access even more Web Development tutorials via the link below:
JavaScript
7
star
67

bootstrap-5-blog-template

Simple blog template. Built with the latest Bootstrap 5 & Material Design.
JavaScript
7
star
68

bootstrap-5-login-cover-template

Simplistic template for a login or registration page. Built with the latest Bootstrap 5 & Material Design.
JavaScript
6
star
69

MDB5-Landing-page-tutorial

MDB5 - Landing page tutorial. Access more Web Development tutorials via the link below
SCSS
5
star
70

MDB5-Blog-tutorial

MDB5 Blog tutorial. Access more Web Development tutorials via the link below
SCSS
5
star
71

bootstrap-video-carousel

Example of responsive bootstrap carousel with videos instead of images built with the Bootstrap 5.
JavaScript
5
star
72

visual-studio-code-bootstap-4

Bootstrap 4 snippets for Visual Studio Code
5
star
73

MDB-Vue-Nuxt-Boilerplate

A MDB Vue & Nuxt.js quick start boilerplate
JavaScript
5
star
74

react-login-form

Responsive login form built with Bootstrap 5. Collection of examples for signup forms, full page login templates, login modals & many other sign in designs.
SCSS
5
star
75

bootstrap-5-full-image-cover-template

Make your website stand out with an image that takes up the entire viewport (fullscreen). Built with the latest Bootstrap 5 & Material Design.
JavaScript
5
star
76

MDB5-Portfolio-page-tutorial

MDB5 Portfolio page tutorial. Access more Web Development tutorials via the link below
SCSS
4
star
77

vue-cli-plugin-mdb

Vue CLI plugin for MDB Vue package.
JavaScript
4
star
78

Angular-PWA-Tutorial-Application

An application created while writing a tutorial on how to create a PWA application in Angular.
TypeScript
4
star
79

React-Template

Template for React Bootstrap Material Design
JavaScript
4
star
80

mdb-angular-contact-form

Contact form with Material Design Angular frontend and Node backend.
TypeScript
4
star
81

MDB-Vue-Laravel-Boilerplate

An MDB Vue & Laravel quick start boilerplate
PHP
4
star
82

bootstrap-weather

Responsive Weather templates built with the latest Bootstrap 5. Examples of UI with icons, cards, real data from API, interactive animated backgrounds.
JavaScript
4
star
83

Facebook-like-chat-with-mdbootstrap-and-socket.io

Tutorial for building a Facebook App. Access more Web Development tutorials via the link below
HTML
4
star
84

bootstrap-mega-menu

Responsive Mega Menu built with Bootstrap 5. Examples of dropdown on click and on hover. Templates with grid, images, links, lists and more.
JavaScript
4
star
85

react-chat

Responsive React Chat built with Bootstrap 5. Many variants of chatbox UI, mobile app, messages box, chat window, chatbot UI, group chat, chat widget, web chat & more. https://mdbootstrap.com/docs/react/extended/chat/
JavaScript
4
star
86

Angular-Tutorial-Agenda-App

This repo contains a lesson files for Angular development tutorial
HTML
4
star
87

bootstrap-to-do-list

Responsive To Do Lists built with the latest Bootstrap 5. Various variants of design and functionality.
JavaScript
4
star
88

react-news-feed

Responsive React News Feed templates built with Bootstrap 5. News article feed, instagram, facebook and twitter-like feed, posts with comments, social section & more. https://mdbootstrap.com/docs/react/extended/news-feed
JavaScript
4
star
89

bootstrap-jumbotron

Responsive Jumbotron built with Bootstrap 5. Examples of classic hero component, with background image, with navbar and many other combinations.
JavaScript
4
star
90

bootstrap-comments

Responsive Comment Box built with the Bootstrap 5. Comment with avatar, nested comments, comment with reply, comment section, comment template, unread comments, comment form.
JavaScript
4
star
91

mdb-starter-vite

HTML
3
star
92

wordpress-blog

3
star
93

bootstrap-5-magazine-template

Template for news & article aggregation. Built with the latest Bootstrap 5 & Material Design.
JavaScript
3
star
94

bootstrap-5-half-carousel-cover-template

Make your website stand out with an image slider/carousel that takes up half a page. Built with the latest Bootstrap 5 & Material Design.
JavaScript
3
star
95

SASS-crash-course-for-beginners

This tutorial will learn you how to use SASS, a CSS with superpowers. Access more Web Development tutorials via the link below
HTML
3
star
96

bootstrap-news-feed

Responsive News Feed built with the latest Bootstrap 5. Enhance your project with a variety of social sections such as news feed, comments, and post cards.
JavaScript
3
star
97

bootstrap-5-one-column-template

A template that will easily help you kick start your project with 2-column based grid. Built with the latest Bootstrap 5 & Material Design.
JavaScript
3
star
98

bootstrap-square-buttons

Responsive Square Buttons built with Bootstrap 5. Black, disabled, full-width outline, social, block square buttons examples.
JavaScript
3
star
99

bootstrap-5-three-columns-template

A template that will easily help you kick start your project with 2-column based grid. Built with the latest Bootstrap 5 & Material Design.
JavaScript
3
star
100

bootstrap-5-full-video-cover-template

Make your website stand out with a video that takes up the entire viewport (fullscreen). Built with the latest Bootstrap 5 & Material Design.
JavaScript
3
star