Split button dropdowns let users pick an action quickly or choose from more options. They combine a main button and a dropdown menu in one control.
Split button dropdowns in Bootsrap
<div class="btn-group"> <button type="button" class="btn btn-primary">Main Action</button> <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true"> <span class="visually-hidden">Toggle Dropdown</span> </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action 1</a></li> <li><a class="dropdown-item" href="#">Action 2</a></li> <li><a class="dropdown-item" href="#">Action 3</a></li> </ul> </div>
The btn-group wraps the buttons and dropdown menu.
The split toggle button uses dropdown-toggle-split and a hidden label for accessibility.
<div class="btn-group"> <button type="button" class="btn btn-success">Save</button> <button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true"> <span class="visually-hidden">Toggle Dropdown</span> </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Save & Close</a></li> <li><a class="dropdown-item" href="#">Save & New</a></li> </ul> </div>
<div class="btn-group"> <button type="button" class="btn btn-danger">Delete</button> <button type="button" class="btn btn-danger dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true"> <span class="visually-hidden">Toggle Dropdown</span> </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Delete Permanently</a></li> <li><a class="dropdown-item" href="#">Archive</a></li> </ul> </div>
This page shows a blue split button with a main action and a dropdown arrow. The dropdown reveals three options. The layout is simple and responsive.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Bootstrap Split Button Dropdown Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <main class="p-4"> <h1>Split Button Dropdown Example</h1> <div class="btn-group" role="group"> <button type="button" class="btn btn-primary">Main Action</button> <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true"> <span class="visually-hidden">Toggle Dropdown</span> </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Option 1</a></li> <li><a class="dropdown-item" href="#">Option 2</a></li> <li><a class="dropdown-item" href="#">Option 3</a></li> </ul> </div> <p class="mt-3">Click the main button to do the main action. Click the arrow to see more options.</p> </main> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Always include aria-expanded and visually-hidden text for screen readers.
Use Bootstrap's JavaScript bundle to enable dropdown functionality.
Split buttons improve usability by separating the main action from other choices.
Split button dropdowns combine a main button and a dropdown arrow in one group.
They save space and make it easy to pick a default or alternative action.
Bootstrap provides simple classes to create accessible and responsive split buttons.
Practice
split button dropdown in Bootstrap?Solution
Step 1: Understand the split button dropdown concept
A split button dropdown combines a main button for a default action and a dropdown toggle for other options.Step 2: Identify the purpose in Bootstrap
Bootstrap uses split buttons to save space and provide quick access to a main action plus alternatives.Final Answer:
To combine a main action button with a dropdown menu for alternative actions -> Option DQuick Check:
Split button = main + dropdown [OK]
- Thinking split button is two separate buttons
- Confusing split button with a single dropdown button
- Assuming split button changes color only
Solution
Step 1: Identify the class for dropdown toggle
Bootstrap uses the classdropdown-toggleto mark the button that toggles the dropdown menu.Step 2: Confirm the correct class for split button toggle
In split buttons, the toggle button must havedropdown-toggleto work properly.Final Answer:
dropdown-toggle -> Option BQuick Check:
Dropdown toggle class = dropdown-toggle [OK]
- Using non-existent classes like btn-toggle
- Confusing btn-split with dropdown-toggle
- Using dropdown-button which is invalid
<div class="btn-group">
<button type="button" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Save as Draft</a></li>
<li><a class="dropdown-item" href="#">Save and Publish</a></li>
</ul>
</div>Solution
Step 1: Analyze the button group structure
The code creates a button group with a main button labeled 'Save' and a split dropdown toggle button next to it.Step 2: Understand the visual effect
The main button is blue (btn-primary) and the toggle button has a small arrow (dropdown-toggle-split) that opens the dropdown menu with two options.Final Answer:
A blue button labeled 'Save' with a small arrow next to it that opens a dropdown menu -> Option CQuick Check:
Split button = main + arrow dropdown [OK]
- Thinking toggle button shows text 'Toggle Dropdown'
- Assuming buttons are separate with no dropdown
- Confusing single button dropdown with split button
<div class="btn-group">
<button class="btn btn-secondary">Options</button>
<button class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action 1</a></li>
</ul>
</div>Solution
Step 1: Check Bootstrap 5 data attribute usage
Bootstrap 5 usesdata-bs-toggleinstead ofdata-toggleto activate dropdowns.Step 2: Identify the incorrect attribute
The code usesdata-toggle="dropdown", which is from Bootstrap 4 and will not work in Bootstrap 5.Final Answer:
Using data-toggle instead of data-bs-toggle for Bootstrap 5 -> Option AQuick Check:
Bootstrap 5 uses data-bs-toggle [OK]
- Forgetting to add dropdown-toggle-split class
- Using old data-toggle attribute
- Changing dropdown-menu from ul to div incorrectly
Solution
Step 1: Understand form submission with split button
The main button should submit the form, so it needstype='submit'inside the form element.Step 2: Add dropdown toggle for alternative options
The dropdown toggle usesdata-bs-toggle='dropdown'to show alternative submission choices without submitting immediately.Final Answer:
Use a <form> with a main button type='submit' and a split dropdown toggle with data-bs-toggle='dropdown' -> Option AQuick Check:
Main button submits form + dropdown toggle shows options [OK]
- Using type='button' on main submit button
- Placing buttons outside the form
- Using single dropdown button without main submit
Ready to prove it?
Pass the test and this pattern moves unknown
