Button Groups

Loading concept...

๐ŸŽฏ Bootstrap Button Groups: Your Button Team!

๐ŸŒŸ The Big Picture

Imagine you have a remote control for your TV. Instead of having buttons scattered all over the room, theyโ€™re all grouped together nicely on one device. Thatโ€™s exactly what Button Groups do in Bootstrap!

Button Groups = Putting buttons together like a family, so they look and work as one team!


๐ŸŽฎ What Are Button Groups?

Think of buttons like LEGO pieces. When you snap them together, they become something bigger and cooler!

The Magic Recipe

<div class="btn-group">
  <button class="btn btn-primary">One</button>
  <button class="btn btn-primary">Two</button>
  <button class="btn btn-primary">Three</button>
</div>

What happens?

  • Buttons stick together (no gaps!)
  • Corners become smooth on the edges
  • They look like ONE control, not separate buttons

๐ŸŽช Real Life Examples

Where You See It What It Does
Music Player โฎ๏ธ โ–ถ๏ธ โญ๏ธ (Previous, Play, Next)
Text Editor B I Uฬฒ (Bold, Italic, Underline)
Email Reply, Reply All, Forward

๐Ÿ“ Button Group Sizing

Just like t-shirts come in S, M, L, XL โ€” button groups can be small, normal, or large!

The Size Chart

graph TD A[Button Group Sizes] --> B[btn-group-sm] A --> C[btn-group - default] A --> D[btn-group-lg] B --> E[๐Ÿœ Small - compact spaces] C --> F[๐Ÿ• Normal - everyday use] D --> G[๐Ÿ˜ Large - easy to tap]

How To Make Them Different Sizes

Small (for tight spaces):

<div class="btn-group btn-group-sm">
  <button class="btn btn-info">A</button>
  <button class="btn btn-info">B</button>
  <button class="btn btn-info">C</button>
</div>

Large (easy to press on phones):

<div class="btn-group btn-group-lg">
  <button class="btn btn-success">Yes</button>
  <button class="btn btn-danger">No</button>
</div>

๐Ÿ’ก Pro Tip: Use btn-group-lg for mobile apps โ€” big buttons = happy thumbs! ๐Ÿ‘


โฌ†๏ธ Button Group Vertical

What if your buttons need to stack up like a tower instead of lining up side by side?

Horizontal vs Vertical

Imagine pancakes:

  • Horizontal = pancakes laid out on a big plate ๐Ÿฅž๐Ÿฅž๐Ÿฅž
  • Vertical = pancakes stacked in a tower! ๐Ÿฅžโฌ‡๏ธ๐Ÿฅžโฌ‡๏ธ๐Ÿฅž

The Code Switch

Just change btn-group to btn-group-vertical:

<div class="btn-group-vertical">
  <button class="btn btn-warning">Top</button>
  <button class="btn btn-warning">Middle</button>
  <button class="btn btn-warning">Bottom</button>
</div>

When To Use Vertical?

Use Vertical Whenโ€ฆ Example
Sidebar menus Navigation links
Mobile layouts Stacked actions
Step-by-step choices Step 1, Step 2, Step 3

๐Ÿช† Button Group Nested

Sometimes you want a group inside a group โ€” like putting a small toy box inside a bigger toy box!

The Nesting Story

Imagine a dropdown menu hiding inside a button group:

<div class="btn-group">
  <button class="btn btn-primary">Save</button>
  <button class="btn btn-primary">Edit</button>

  <div class="btn-group">
    <button class="btn btn-primary dropdown-toggle"
            data-bs-toggle="dropdown">
      More โ–ผ
    </button>
    <ul class="dropdown-menu">
      <li><a class="dropdown-item" href="#">Copy</a></li>
      <li><a class="dropdown-item" href="#">Delete</a></li>
    </ul>
  </div>
</div>

๐ŸŽ Whatโ€™s Happening Here?

graph TD A[Main Button Group] --> B[Save Button] A --> C[Edit Button] A --> D[Nested Button Group] D --> E[More Dropdown Button] E --> F[Copy Option] E --> G[Delete Option]

Key Point: The nested btn-group sits inside the parent btn-group. The dropdown is INSIDE the nested group!


๐Ÿ”ง Button Toolbar

What if you need multiple button groups working together? Like having several tool sections on a workbench!

The Toolbar Concept

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  [Group 1]    [Group 2]    [Group 3]     โ”‚
โ”‚  ๐Ÿ“ Edit       ๐ŸŽจ Style     ๐Ÿ“ค Share      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Building a Toolbar

<div class="btn-toolbar">
  <div class="btn-group me-2">
    <button class="btn btn-secondary">Cut</button>
    <button class="btn btn-secondary">Copy</button>
    <button class="btn btn-secondary">Paste</button>
  </div>

  <div class="btn-group me-2">
    <button class="btn btn-secondary">Bold</button>
    <button class="btn btn-secondary">Italic</button>
  </div>

  <div class="btn-group">
    <button class="btn btn-secondary">Align</button>
  </div>
</div>

๐Ÿงฉ Toolbar Rules

Class What It Does
btn-toolbar Creates the toolbar container
btn-group Each button cluster
me-2 Adds space between groups

Think of it like: A toolbox (btn-toolbar) with different compartments (btn-group) holding related tools!


๐ŸŽฏ Quick Summary

Feature Class Purpose
Basic Group btn-group Join buttons together
Small Size btn-group-sm Compact buttons
Large Size btn-group-lg Big, easy-to-tap buttons
Vertical Stack btn-group-vertical Stack buttons top-to-bottom
Nested Group btn-group inside btn-group Add dropdowns inside groups
Toolbar btn-toolbar Organize multiple groups

๐ŸŒˆ Remember This!

Button Groups are like:

  • ๐ŸŽน Piano keys (side by side)
  • ๐Ÿ“š Books on a shelf (organized together)
  • ๐ŸŽช A team of performers (working as one)

The Golden Rules:

  1. Wrap buttons in div class="btn-group"
  2. Add size classes to the group, not buttons
  3. Use btn-group-vertical for stacking
  4. Nest groups for dropdowns
  5. Use btn-toolbar for multiple groups

Youโ€™ve got this! ๐Ÿš€ Button groups make your buttons look professional and organized. Now go build something awesome!

Loading story...

No Story Available

This concept doesn't have a story yet.

Story Preview

Story - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

Interactive Preview

Interactive - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Interactive Content

This concept doesn't have interactive content yet.

Cheatsheet Preview

Cheatsheet - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Cheatsheet Available

This concept doesn't have a cheatsheet yet.

Quiz Preview

Quiz - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Quiz Available

This concept doesn't have a quiz yet.