Buttons

Loading concept...

🎨 Bootstrap Buttons: Your Magic Toolkit!

Imagine you’re building a toy control panel. You need buttons that do different things – some are big and important, some are small and subtle. Bootstrap buttons are exactly like that! They’re pre-made, beautiful buttons you can use on any website.


🌟 What Are Bootstrap Buttons?

Think of Bootstrap buttons like LEGO blocks for websites. Instead of building buttons from scratch, you just pick the one you want!

The Magic Word: .btn

Every Bootstrap button starts with this class. It’s like saying “Hey, I want to be a button!”

<button class="btn">
  I'm a Button!
</button>

That’s it! Just add class="btn" and you have a styled button.


🎭 Button Variants: Pick Your Color!

Imagine a box of crayons. Each color has a meaning:

Color Class What It Means
🔵 Blue btn-primary “This is important!”
⚫ Gray btn-secondary “I’m here if you need me”
🟢 Green btn-success “Yay! Something good!”
🔴 Red btn-danger “Warning! Be careful!”
🟡 Yellow btn-warning “Hmm, pay attention!”
🩵 Cyan btn-info “Here’s some info”
⚪ Light btn-light Soft and gentle
âš« Dark btn-dark Bold and strong
đź”— Link btn-link Looks like a link!

Example:

<button class="btn btn-primary">
  Save
</button>

<button class="btn btn-danger">
  Delete
</button>

<button class="btn btn-success">
  Done!
</button>

🎯 Remember: Always use btn PLUS a color class!


🖼️ Button Outline: The Frame, Not the Fill!

Sometimes you want a button that’s NOT filled with color. Just the outline – like a coloring book before you color it!

Just add outline to the class name:

<button class="btn btn-outline-primary">
  Outline Blue
</button>

<button class="btn btn-outline-danger">
  Outline Red
</button>

<button class="btn btn-outline-success">
  Outline Green
</button>

When to use outlines?

  • When filled buttons feel “too loud”
  • For secondary actions (like “Cancel”)
  • To create visual hierarchy
graph TD A[User Sees Buttons] --> B{Which catches eye first?} B --> C[Filled Button - PRIMARY] B --> D[Outline Button - SECONDARY] C --> E[User clicks main action] D --> F[User clicks alternative]

📏 Button Sizes: Small, Medium, Large!

Like T-shirts, buttons come in sizes:

Size Class Use When
Large btn-lg Big important buttons
Normal (no class) Everyday buttons
Small btn-sm Compact spaces

Example:

<button class="btn btn-primary btn-lg">
  BIG Button
</button>

<button class="btn btn-primary">
  Normal Button
</button>

<button class="btn btn-primary btn-sm">
  tiny button
</button>

đź’ˇ Pro Tip: Size classes go AFTER the color class!


🚫 Disabled Buttons: “Sorry, Not Now!”

Sometimes a button shouldn’t work yet. Like a “Submit” button before you fill out a form.

Two ways to disable:

1. Using the disabled attribute (for <button>):

<button class="btn btn-primary" disabled>
  Can't Click Me
</button>

2. Using .disabled class (for <a> links):

<a class="btn btn-primary disabled">
  Can't Click Me Either
</a>

What happens when disabled?

  • Button looks faded (50% opacity)
  • Cursor shows “not allowed” ❌
  • Click events don’t work
graph TD A[Form Empty] --> B[Button Disabled] B --> C{User fills form} C --> D[Form Valid] D --> E[Button Enabled!] E --> F[User can submit]

📦 Block Buttons: Full Width Power!

Want a button that stretches across the entire width? Like a banner?

The Modern Way (Bootstrap 5):

<div class="d-grid">
  <button class="btn btn-primary">
    I Take All The Space!
  </button>
</div>

Multiple block buttons with gap:

<div class="d-grid gap-2">
  <button class="btn btn-primary">
    First Big Button
  </button>
  <button class="btn btn-secondary">
    Second Big Button
  </button>
</div>

When to use block buttons?

  • Mobile apps (easier to tap!)
  • Call-to-action sections
  • Login/signup forms

🔄 Button Toggle States: On and Off!

Remember light switches? Toggle buttons work the same way – they remember if they’re ON or OFF.

Using data-bs-toggle="button":

<button class="btn btn-primary"
        data-bs-toggle="button">
  Click to Toggle
</button>

Pre-activated toggle (starts as “on”):

<button class="btn btn-primary active"
        data-bs-toggle="button"
        aria-pressed="true">
  Already Active!
</button>

What changes when toggled?

  • Button gets .active class
  • Background becomes slightly darker
  • aria-pressed switches between true/false
graph TD A[Button Normal] --> B{User Clicks} B --> C[Button Active] C --> D{User Clicks Again} D --> A

🎯 Quick Summary

What You Want What You Write
Basic button btn
Blue button btn btn-primary
Outline button btn btn-outline-*
Big button btn btn-* btn-lg
Small button btn btn-* btn-sm
Can’t click disabled attribute
Full width Wrap in d-grid
Toggle on/off data-bs-toggle="button"

🚀 You Did It!

Now you know how to:

  • âś… Create any color button
  • âś… Make outline versions
  • âś… Change sizes
  • âś… Disable buttons
  • âś… Create full-width buttons
  • âś… Make toggleable buttons

Go build something amazing! 🎉

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.