Sanity UI array syntax for padding and breakpoints explanation
Exactly! Yes, those array props in Sanity UI are for responsive breakpoints.
When you write something like padding={[3, 3, 4]}, you're defining different padding values at different viewport breakpoints. The array maps to Sanity UI's built-in media query breakpoints:
- Index 0 (first value): applies at the smallest breakpoint (default: 0px)
- Index 1 (second value): applies at the next breakpoint (default: 360px)
- Index 2 (third value): applies at the next breakpoint (default: 600px)
- And so on for larger breakpoints (900px, 1200px, etc.)
So padding={[3, 3, 4]} means:
- Padding of
3at 0px and above - Padding of
3at 360px and above - Padding of
4at 600px and above
This pattern is called responsive props in Sanity UI, and it works across many components and properties like padding, margin, fontSize, space, etc. It's a convenient way to handle responsive design without writing media queries manually.
The Sanity UI documentation mentions that "many primitives support responsive properties through arrays, allowing different values at various breakpoints for properties like size, padding, and spacing." This approach is inspired by similar patterns in other design systems like Theme UI and Styled System, making it familiar if you've used those libraries before.
You can see this pattern in action throughout the Sanity UI codebase—look at components like Box, Stack, Text, and others that accept spacing and sizing props.
Show original thread2 replies
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.