githubEdit

Bootstrap Usage Guide

This guide establishes consistent patterns for using Bootstrap 5 classes throughout the Gyrinx codebase.

Core Principles

  1. Mobile-first: Design for mobile, scale up to desktop

  2. Prefer utility stacks: Use hstack/vstack over d-flex for most layouts

  3. Consistent spacing: Use gap utilities instead of margin classes within stacks

  4. Minimal card usage: Reserve cards primarily for fighter cards in list grids

  5. 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-sm

  • Secondary actions: btn btn-secondary btn-sm

  • Danger actions: btn btn-danger btn-sm

  • Outline 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

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:

  1. Replace d-flex with hstack/vstack where appropriate

  2. Remove redundant margin classes inside stacks

  3. Ensure all buttons use btn-sm

  4. Replace alert divs with simpler text or bordered divs

  5. Add consistent p-2 padding to card headers

  6. Use gap utilities instead of individual margins

  7. Apply responsive utility classes for mobile-first design

Testing

After making Bootstrap changes:

  1. Test on mobile viewport (375px)

  2. Test on tablet viewport (768px)

  3. Test on desktop viewport (1200px)

  4. Verify interactive elements are touch-friendly

  5. Check for consistent spacing and alignment

Last updated