Breakpoints
Tailwind CSS uses a default set of breakpoints. You can customize them, but Sabo uses the standard configuration:| Breakpoint | Minimum Width | CSS Prefix |
|---|---|---|
sm | 640px | @media (min-width: 640px) |
md | 768px | @media (min-width: 768px) |
lg | 1024px | @media (min-width: 1024px) |
xl | 1280px | @media (min-width: 1280px) |
2xl | 1536px | @media (min-width: 1536px) |
Applying Responsive Styles
To make a design responsive, use breakpoint prefixes with Tailwind’s utility classes. Classes without a prefix apply to all screen sizes (mobile-first), and prefixed classes override the base styles at a specific breakpoint and above. For example, let’s create a layout that is a single column on mobile and a two-column grid on larger screens.ResponsiveLayout.tsx
grid-cols-1: On mobile (the default), the grid has one column.md:grid-cols-2: On screens 768px and wider, the grid changes to two columns.lg:grid-cols-3: On screens 1024px and wider, it becomes a three-column grid. Thelgstyle will persist for all larger screen sizes (xl,2xl, etc.) unless overridden.
You can apply these prefixes to any Tailwind utility class, such as
lg:text-lg, sm:p-8, md:flex, etc.Responsive Hooks
For more complex responsive logic in your components, Sabo provides two helpful custom hooks.useIsMobile()
useIsMobile()
This hook returns
true if the current screen width is less than 768px (the md breakpoint). It’s useful for conditionally rendering different components on mobile vs. desktop.Location: src/hooks/use-mobile.tsClientComponent.tsx
useMediaQuery()
useMediaQuery()
For more granular control,
useMediaQuery lets you check against any custom CSS media query. It returns true if the query matches.Location: src/hooks/use-media-query.tsAdvancedComponent.tsx