Grid System - Quick Start Guide

Master the data-driven responsive grid in 5 minutes

Back to Examples

What Makes RSL Grid Different

Instead of rigid column classes like .col-4 and .col-8, RSL uses a flexible data-driven system:

2-Minute Setup

1 Include Files

Required Files • HTML


    
                

2 Create Your Grid

Basic Grid • HTML

Item 1
Item 2
Item 3
✓ Done! This creates: 1 column on mobile (xs), 3 columns from md breakpoint up.

Breakpoints Reference

BreakpointScreen WidthAttribute
xs (Extra Small)0 - 575pxdata-cols-xs="N"
sm (Small)576px - 767pxdata-cols-sm="N"
md (Medium)768px - 991pxdata-cols-md="N"
lg (Large)992px - 1199pxdata-cols-lg="N"
xl (Extra Large)1200px - 1399pxdata-cols-xl="N"
xxl (2X Large)1400px+data-cols-xxl="N"

Inheritance: Set Once, Apply Everywhere

Key Concept: RSL uses breakpoint inheritance. If you set data-cols-md="4", it automatically applies to md, lg, xl, and xxl—unless you override a larger breakpoint.
Inheritance Example • HTML


Item

Pro Tips

✨ Tip 1: Start mobile-first with data-cols-xs, then add larger breakpoints as needed
✨ Tip 2: For equal columns, just set data-cols-md="3"—no need for complex math
✨ Tip 3: Use data-slots-* for fractional widths (1/3, 2/3) instead of equal columns
✨ Tip 4: Combine with .slot-layout nesting for complex layouts

Working with Dynamic Content

Grid layouts are calculated when the page loads and on window resize. However, if you're using grids inside components that show/hide content (like tabs, accordions, or modals), you may need to trigger a layout recalculation when the content becomes visible.

Problem: Grids Inside Hidden Content

When grid layouts are inside hidden elements (display: none), they can't be properly measured during the initial calculation. This commonly happens with:

Solution: Trigger Layout Recalculation

The layout.js script automatically recalculates grids on window resize events. You can leverage this to force recalculation when content becomes visible:

Trigger Grid Recalculation • JavaScript

// When showing previously hidden content with grids inside
function showContent(contentElement) {
    // Make content visible
    contentElement.classList.add('active');

    // Trigger layout recalculation
    window.dispatchEvent(new Event('resize'));
}
                

Example: Tabs Component

Tab Switch with Grid Recalculation • JavaScript

function activateTab(tab, content) {
    // Hide all tab panels
    document.querySelectorAll('.tab-content').forEach(panel => {
        panel.classList.remove('active');
    });

    // Show selected tab panel
    content.classList.add('active');

    // Recalculate any grids inside the newly visible tab
    const grids = content.querySelectorAll('.slot-layout');
    if (grids.length > 0) {
        window.dispatchEvent(new Event('resize'));
    }
}
                

✓ Best Practice: Always trigger a resize event when revealing content that contains .slot-layout grids. This ensures proper column calculation and responsive behavior.

ADA Compliance

RSL Grid is accessibility-friendly:

  • ✅ Semantic HTML with <div> containers
  • ✅ Responsive design benefits all users
  • ✅ Content reflows naturally on zoom
  • ✅ Keyboard navigation through grid items
Back to Examples