Bootstrap Usage Guide
This guide establishes consistent patterns for using Bootstrap 5 classes throughout the Gyrinx codebase.
Core Principles
Mobile-first: Design for mobile, scale up to desktop
Prefer utility stacks: Use
hstack/vstackoverd-flexfor most layoutsConsistent spacing: Use gap utilities instead of margin classes within stacks
Minimal card usage: Reserve cards primarily for fighter cards in list grids
Semantic HTML: Use appropriate HTML elements with Bootstrap utilities
Layout Patterns
Horizontal and Vertical Stacks
DO: Use hstack and vstack for simple layouts
<div class="vstack gap-2">
<div class="hstack gap-2">
<span>Label:</span>
<span>Value</span>
</div>
</div>DON'T: Use d-flex for simple layouts
EXCEPTION: Use d-flex only for complex responsive layouts
Spacing
DO: Use gap utilities on stacks
DON'T: Use margin classes inside stacks
EXCEPTION: Use mb-0 on headings to remove default margins
Standard Header Pattern
For list/campaign detail pages:
Component Usage
Cards
DO: Use cards for fighter cards in list grids
DON'T: Use cards for general content sections
Buttons
All buttons should use the small size for consistency:
Primary actions:
btn btn-primary btn-smSecondary actions:
btn btn-secondary btn-smDanger actions:
btn btn-danger btn-smOutline variants:
btn btn-outline-secondary btn-sm
Messages and Alerts
DO: Use simple text for informational messages
DON'T: Use Bootstrap alerts for simple messages
DO: Use bordered divs for important callouts
Links
Use consistent link styling:
Responsive Patterns
Responsive Column Classes
Both grid systems are acceptable for different use cases:
g-col-12 g-col-md-6: CSS Grid (for grid layouts)col-12 col-md-6: Flexbox Grid (for row/column layouts)
Responsive Utilities
Use responsive utility classes for different screen sizes:
Common Patterns
Form Groups
Action Button Groups
Empty States
Migration Checklist
When updating existing templates:
Replace
d-flexwithhstack/vstackwhere appropriateRemove redundant margin classes inside stacks
Ensure all buttons use
btn-smReplace
alertdivs with simpler text or bordered divsAdd consistent
p-2padding to card headersUse gap utilities instead of individual margins
Apply responsive utility classes for mobile-first design
Testing
After making Bootstrap changes:
Test on mobile viewport (375px)
Test on tablet viewport (768px)
Test on desktop viewport (1200px)
Verify interactive elements are touch-friendly
Check for consistent spacing and alignment
Last updated