Skip to main content
Theme UI uses an array-based syntax for responsive styles, enabling mobile-first responsive design with minimal code.

Array-Based Syntax

Provide an array of values that map to breakpoints:
This creates responsive styles:

Breakpoints

Define breakpoints in your theme:
Default breakpoints from the source code:

Custom Breakpoints

You can use any CSS length unit:
Or with custom media queries:

Mobile-First Approach

The first value in the array is the base (mobile) style. Each subsequent value applies at the corresponding breakpoint:
Breakdown:
  • 100% - Mobile (default)
  • 50% - Tablet and up (≥ 40em)
  • 33.333% - Desktop and up (≥ 52em)
  • 25% - Large desktop (≥ 64em)

Responsive Implementation

Here’s how Theme UI transforms responsive arrays (from the source code):

Skipping Breakpoints

Use null or undefined to skip a breakpoint:
This applies:
  • 100% at mobile
  • No change at first breakpoint
  • 50% at second breakpoint

Multiple Responsive Properties

Combine multiple responsive properties:

Responsive Typography

Responsive Layout

Create responsive layouts:

Responsive Spacing

Nested Responsive Styles

Responsive arrays work in nested objects:

Responsive Variants

Combine responsive arrays with variants:

Working with Grid and Flexbox

Responsive Flexbox

Responsive Grid

Responsive Display

Show/hide elements at different breakpoints:

TypeScript Support

Responsive arrays are fully typed:

Best Practices

Start Mobile-First

Always define the mobile style first:

Use Consistent Breakpoints

Define breakpoints that match your design system:

Combine with Theme Scales

Use theme values in responsive arrays:

Real-World Example

A complete responsive card component:
Responsive arrays provide a concise, mobile-first way to create responsive designs without writing media queries manually.