All components and styles assigned within the design system are by default naturally responsive and intentionally wrap when screen widths are smaller.
To construct custom responsive layouts the design system offers a mobile first approach with the following tools:
The following breakpoints are available both in JavaScript and as CSS Variables, the responsive styles are dependent on the breakpoints token and each value refers to the minimum width of the breakpoint.
The breakpoints then are available as minimum widths as tokens, in the mediaQuery min object and as CSS variables:
The breakpoints then are available as maximum widths as tokens, in the mediaQuery max object and as CSS variables:
The layout components and additionally Heading, List and Text components offer flexible customisation at the defined breakpoints. It is possible to apply responsive styling to the aforementioned components as:
Output as a single value string no breakpoints are applied and this style is applied to the component.
1<Box backgroundColor="tertiary" color="text" padding="--s4">2 <p>Inspect me to see styles</p>3</Box>
Inspect me to see styles
An array of string values is output where the first value is set to the first breakpoint (xs), the second value is then set to the second breakpoint (sm) and so on. To skip a breakpoint a 'null' value can be entered.
1<Box backgroundColor="tertiary" color="text" padding={['--s1', '--s2', '--s3']}>2 <p>Inspect me to see styles</p>3</Box>
Inspect me to see styles
An object provides the ability to set a specific breakpoint.
1<Box backgroundColor="tertiary" color="text" padding={{m: '--s1', l: '--s2', xxxl: '--s3'}}>2 <p>Inspect me to see styles</p>3</Box>
Inspect me to see styles
A custom hook: useWindowSize is available to provide a value of the current windows width or height, this can be used to output different layouts or functionality within React / JavaScript.
An example of how to use useWindowSize:
1const { windowWidth } = useWindowSize()2if(windowWidth > breakpoint.lg) { // do this }