React

Responsive Design

Learn how to adjust layouts and styles according to viewport size.

Crispy provides a mobile-first responsive system. When you specify a value at a specific breakpoint, that same value is applied to wider viewports.

Breakpoints

Namemin-width
base0px
sm480px
md768px
lg1280px
xl1440px

Using Responsive Props in Layout Components

Box and Box-based components (Flex, Grid, VStack, HStack, etc.) can accept objects with breakpoint names as keys for layout property values.

<Box padding={{ base: "x3", md: "x4" }} />
CategoryProperty
Layoutdisplay, flexDirection, gap
Sizingwidth, minWidth, maxWidth, height, minHeight, maxHeight
Paddingpadding, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft, p, px, py, pt, pr, pb, pl
BleedbleedX, bleedY, bleedTop, bleedRight, bleedBottom, bleedLeft

Hiding & Showing Elements

You can pass responsive values to display to show or hide elements at specific breakpoints.

hideFrom

Use hideFrom to hide elements at a specific breakpoint and above. (display: none;)

Can be used in Box and Box-based components (Flex, Grid, VStack, HStack, etc.).

hideFrom="md" is equivalent to display={{ md: "none" }}.

Grid

You can specify columns and rows attributes for each breakpoint.

Grid

Grid component uses CSS Grid and helps you use design tokens in JSX.

Hooks

Provides useBreakpoint and useBreakpointValue hooks implemented based on window.matchMedia.

Whenever possible, use responsive props that work CSS-based, and use hooks only when JS logic is needed.

useBreakpoint

Returns the current breakpoint name.

base

useBreakpointValue

Resolves the responsive value object passed as a parameter to the value that matches the current viewport.

Server-Side Rendering

To define a default breakpoint value to be applied when using hooks in an environment where viewport information is unknown (such as SSR), specify defaultBreakpoint via BreakpointProvider.

If you call a hook outside BreakpointProvider but window.matchMedia is not available, useBreakpoint returns base, and useBreakpointValue returns the value of the base key.

import { BreakpointProvider } from "@seed-design/react";

function App() {
  return (
    <BreakpointProvider defaultBreakpoint="md">
      <MyApp />
    </BreakpointProvider>
  );
}

Table of contents