Lesson 18: Creating a Dropdown Menu in Bootstrap 5

Dropdown menus in Bootstrap 5 are a cool feature you shouldnt miss. Heres how to use dropdown menus in Bootstrap 5.

Dropdown menus in Bootstrap 5 are a cool feature you shouldn't miss. Here's how to use dropdown menus in Bootstrap 5 .

 

Create a basic dropdown menu.

A dropdown menu is a toggleable menu that allows the user to select a value from a predefined list. Essentially, it would look like this:

 

 

Detailed explanation:

This class .dropdownrepresents a dropdown menu.

To open this menu, use a button or link containing the class .dropdown-toggleand attribute data-bs-toggle="dropdown".

Add a class .dropdown-menuto the element to create a real dropdown menu. Then add the class .dropdown-itemto each element (link or button) inside the dropdown menu.

For example:

 Bootstrap Example 

Dropdown menu

 

 

Split dropdown menu

The `.dropdown-divider` class is used to separate the links within a dropdown menu with a thin horizontal border:

For example:

 Bootstrap Example 

Split dropdown menu

 

 

Dropdown menu header

This class .dropdown-headeris used to add headers inside the dropdown menu:

For example:

 Bootstrap Example 

Dropdown menu

 

 

Disabled and enabled items

Highlight a specific dropdown item using a class .active(add a blue background color).

To disable an item in a dropdown menu, use the class .disabled(which has light gray text and no mouse cursor effect):

  • Normal
  • Active
  • Disabled

For example:

 Bootstrap Example 

The dropdown menu has disabled items highlighted in light gray.

 

 

Drop-off location

You can also create a "dropend" (drop-down on the right) or "dropstart" (drop-down on the left) menu by adding the class .dropend or .dropstart to the dropdown element. Note that the caret/arrow is added automatically.

Drop it to the right:

Drop it to the left:

For example:

Menu dropend:

 Bootstrap Example 

Menu drop-down menu

Add .dropend next to the dropdown menu to right-align it. Carets and arrows are added automatically;

 

Dropstart menu:

 Bootstrap Example 

Dropstart menu

Add .dropstart next to the dropdown menu to align it to the left.

 

To the right of the dropdown menu

To align the dropdown menu to the right, add the .dropdown-menu-endfollowing class to this element .dropdown-menu:

 

For example:

 Bootstrap Example 

The dropdown menu is on the right.

 

Dropup

If you want the dropdown menu to expand upwards instead of dropping down, change the element with class='dropdown' to 'dropup' : :

 

For example:

 Bootstrap Example 

Dropdown menu

The `.dropup` class makes the dropdown menu expand upwards instead of downwards:

Note that there must be space for the expandable dropup menu.

Text dropdown

The class .dropdown-item-textis used to add plain text to a dropdown menu or to use links for the default link style:

For example:

 Bootstrap Example 

The dropdown menu contains text or a link.

 

Group buttons with dropdown menus

The basic code is as follows:

   

For example:

 Bootstrap Example 

Nested button groups to create a dropdown menu.

   

Vertical button layout with dropdown menu

Basic code:

   

For example:

 Bootstrap Example 

Group the buttons vertically with the dropdown menu.

   

Above is how to create a dropdown menu using Bootstrap 5. As you can see, it's not too difficult if you take the time to learn a little. Good luck!

Related posts
  • How to customize Bootstrap with Sass

    bootstrap is a fantastic css framework that can help you create stylish and polished websites. some programmers and development teams find that writing code in bootstrap is easier to edit than regular css.
  • Lesson 41: Grid Medium in Bootstrap 5

    in the previous bootstrap 5 lesson, you learned how to create grids with classes for small screens. however, on medium-sized devices with better designs, the grid is often divided 50%/50%.
  • Lesson 40: Small Grid in Bootstrap 5

    continuing our lesson on grids in bootstrap 5, we'll learn how to create the simplest small grid. basically, creating a small grid using bootstrap 5 isn't difficult.
  • Lesson 1: What is Bootstrap 5? How to get started?

    using bootstrap 5 isn't too difficult. this article will tell you what bootstrap 5 is and how to use it.
  • Update the latest Bootstrap

    with the latest version, bootstrap 5.3.0, this framework has introduced a set of exciting new features and powerful improvements for multi-purpose web and app development.
Other Program articles
  • Lesson 16: List Groups in Bootstrap 5

    list group hay nhóm danh sách trong bootstrap 5 là một thành phần linh hoạt và mạnh mẽ để hiển thị một chuỗi thông tin.hãy cùng quantrimang.com tìm hiểu cách dùng list-group trong bootstrap 5 nhé!
  • Lesson 15: Pagination in Bootstrap 5

    phần bài học bootstrap cơ bản này sẽ thảo luận về tính năng phân trang hay pagination. bootstrap 5 xử lý danh sách không theo đúng thứ tự giống như rất nhiều các nhân tố khác trên giao diện.
  • Lesson 14: Spinner in Bootstrap 5

    spinner trong boostrap 5 là gì? cách dùng spinner trong boostrap 5 như thế nào? hãy cùng tipsmake.com tìm hiểu nhé!
  • Lesson 13: Progress Bars in Bootstrap 5

    trong bài viết này, quantrimang sẽ tiếp tục hướng dẫn bạn sử dụng bootstrap để tạo các thanh tiến trình - progress bar.
  • Lesson 12: Badges in Bootstrap 5

    badge trong bootstrap rất cần thiết khi phát triển web và ứng dụng. Ở bài này, hãy cùng tipsmake.com.com tìm hiểu cách dùng badge trong bootstrap như thế nào nhé!
  • Lesson 11: Button Groups in Bootstrap 5

    btn-group bootstrap 5 là gì? cách tạo hay dùng button trong bootstrap 5 như thế nào? hãy cùng tipsmake.com.com tìm hiểu nhé!
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup