← Back to Bootstrap Course | Chapter 5: Components — Buttons & Forms | Lesson 3 of 7

Button के Groups

Button groups related buttons को एक connected bar में जोड़ते हैं।

In this page:

  1. Button Groups
Syntax
markup
<div class="btn-group" role="group" aria-label="label">
  <button class="btn btn-primary">one</button>
  <button class="btn btn-primary">two</button>
</div>

Button Groups

Buttons को role="group" और एक aria-label वाली .btn-group में wrap करें। इन्हें stack करने के लिए .btn-group-vertical और कई groups combine करने के लिए .btn-toolbar इस्तेमाल करें। .btn-check वाले Radio और checkbox toggles भी button groups की तरह render होते हैं।

Note: Accessibility के लिए हमेशा role="group" और एक aria-label add करें।

उदाहरण: Button groups

markup
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
  <div class="btn-group mb-3" role="group" aria-label="Text alignment">
    <button type="button" class="btn btn-outline-primary">Left</button>
    <button type="button" class="btn btn-outline-primary active">Middle</button>
    <button type="button" class="btn btn-outline-primary">Right</button>
  </div>
  <div class="btn-group-vertical d-block" role="group" aria-label="Vertical group" style="width:8rem">
    <button type="button" class="btn btn-secondary">Top</button>
    <button type="button" class="btn btn-secondary">Bottom</button>
  </div>
</div>
</body>
</html>
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. role और aria-label भूल जाना
  2. groups को गलत तरीके से nest करना
  3. unrelated buttons के लिए groups इस्तेमाल करना
चैप्टर सारांश
  • .btn-group buttons जोड़ता है
  • role="group" और aria-label
  • btn-group-vertical stack करता है
  • btn-toolbar groups combine करता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.