Buttons start with the .btn base class plus a variant: btn-primary, btn-outline-secondary, btn-link. Size with btn-sm or btn-lg; group related actions with btn-group.
Semantics matter
Use <button type="button"> for actions and <a class="btn"> for navigation. Disabled state: disabled attribute or .disabled class on links. Review accessible labels in HTML forms when buttons submit data.
Compared to Tailwind
Tailwind builds buttons from utilities (rounded-lg bg-blue-600 px-4 py-2). Bootstrap encodes hover, focus, and contrast in component classes—faster to prototype, less pixel-pushing per state.
Important interview questions and answers
- Q: btn vs btn-outline-primary?
A: Solid fills usebtn-*; outline variants keep transparent backgrounds with colored borders—better on busy backgrounds. - Q: When use btn-group?
A: Segmented controls, pagination-style toolbars, or mutually adjacent actions that should share borders.
Self-check
- What two classes create a small primary button?
- Why prefer
buttonoverdivfor clickable actions?