Devup UI uses a mobile-first responsive design system with 6 breakpoints. Use arrays to apply different styles at different viewport widths.
| Index | Breakpoint | Range | Device |
|---|---|---|---|
| 0 | xs | 0px - 479px | Mobile (portrait) |
| 1 | sm | 480px - 767px | Mobile (landscape) |
| 2 | md | 768px - 991px | Tablet |
| 3 | lg | 992px - 1279px | Small desktop |
| 4 | xl | 1280px - 1599px | Desktop |
| 5 | 2xl | 1600px+ | Large desktop |
Pass an array to any style prop. Each index corresponds to a breakpoint:
1<Box bg={['red', 'blue', 'green', 'yellow', 'purple', 'orange']} />1<Box bg={['red', 'blue', 'green', 'yellow', 'purple', 'orange']} />
This results in:
null to Skip BreakpointsUse null to skip a breakpoint and keep the previous value:
1<Box bg={['red', null, 'green', null, 'purple']} />1<Box bg={['red', null, 'green', null, 'purple']} />
This results in:
Arrays shorter than 6 elements apply styles up to their length:
1// Only define mobile and desktop 2const example = <Box fontSize={['14px', null, null, null, '18px']} /> 3 4// Shorthand: mobile and tablet only 5const example2 = <Box p={[2, 4]} />1// Only define mobile and desktop 2const example = <Box fontSize={['14px', null, null, null, '18px']} /> 3 4// Shorthand: mobile and tablet only 5const example2 = <Box p={[2, 4]} />
1<Flex direction={['column', null, 'row']} gap={[2, null, 4]}> 2 <Box p={[2, null, 4]} w={['100%', null, '50%']}> 3 Left content 4 </Box> 5 <Box p={[2, null, 4]} w={['100%', null, '50%']}> 6 Right content 7 </Box> 8</Flex>1<Flex direction={['column', null, 'row']} gap={[2, null, 4]}> 2 <Box p={[2, null, 4]} w={['100%', null, '50%']}> 3 Left content 4 </Box> 5 <Box p={[2, null, 4]} w={['100%', null, '50%']}> 6 Right content 7 </Box> 8</Flex>
Combine with typography for responsive text:
1<Text 2 fontSize={['24px', null, null, null, '48px']} 3 lineHeight={[1.3, null, null, null, 1.2]} 4> 5 Responsive Heading 6</Text>1<Text 2 fontSize={['24px', null, null, null, '48px']} 3 lineHeight={[1.3, null, null, null, 1.2]} 4> 5 Responsive Heading 6</Text>
Or use responsive typography from devup.json:
1{ 2 "theme": { 3 "typography": { 4 "h1": [ 5 { "fontSize": "32px", "fontWeight": 800 }, 6 null, 7 null, 8 null, 9 { "fontSize": "48px", "fontWeight": 800 } 10 ] 11 } 12 } 13}1{ 2 "theme": { 3 "typography": { 4 "h1": [ 5 { "fontSize": "32px", "fontWeight": 800 }, 6 null, 7 null, 8 null, 9 { "fontSize": "48px", "fontWeight": 800 } 10 ] 11 } 12 } 13}
1<Text typography="$h1">Responsive Heading</Text>1<Text typography="$h1">Responsive Heading</Text>
Combine responsive arrays with pseudo selectors:
1// Different hover colors per breakpoint 2const example = <Box _hover={{ bg: ['blue', null, 'purple'] }} /> 3 4// Alternative syntax 5const example2 = <Box _hover={[{ bg: 'blue' }, null, { bg: 'purple' }]} />1// Different hover colors per breakpoint 2const example = <Box _hover={{ bg: ['blue', null, 'purple'] }} /> 3 4// Alternative syntax 5const example2 = <Box _hover={[{ bg: 'blue' }, null, { bg: 'purple' }]} />
1// Hide on mobile, show on desktop 2const example = ( 3 <Box display={['none', null, null, null, 'block']}>Desktop only content</Box> 4) 5 6// Show on mobile, hide on desktop 7const example2 = ( 8 <Box display={['block', null, null, null, 'none']}>Mobile only content</Box> 9)1// Hide on mobile, show on desktop 2const example = ( 3 <Box display={['none', null, null, null, 'block']}>Desktop only content</Box> 4) 5 6// Show on mobile, hide on desktop 7const example2 = ( 8 <Box display={['block', null, null, null, 'none']}>Mobile only content</Box> 9)
1<Grid 2 gap={[2, null, 4]} 3 templateColumns={['1fr', null, 'repeat(2, 1fr)', null, 'repeat(4, 1fr)']} 4> 5 <Box>Item 1</Box> 6 <Box>Item 2</Box> 7 <Box>Item 3</Box> 8 <Box>Item 4</Box> 9</Grid>1<Grid 2 gap={[2, null, 4]} 3 templateColumns={['1fr', null, 'repeat(2, 1fr)', null, 'repeat(4, 1fr)']} 4> 5 <Box>Item 1</Box> 6 <Box>Item 2</Box> 7 <Box>Item 3</Box> 8 <Box>Item 4</Box> 9</Grid>
1<Box m={[2, null, 4]} p={[2, null, 4, null, 6]}> 2 Content with responsive padding and margin 3</Box>1<Box m={[2, null, 4]} p={[2, null, 4, null, 6]}> 2 Content with responsive padding and margin 3</Box>
Remember: numeric values are multiplied by 4. So p={[2, null, 4]} becomes padding: 8px on mobile and padding: 16px on tablet+.