Responsive styles
Describe how a component changes at breakpoints with sparse responsive values.
Responsive objects
A base value applies first. Named breakpoints override it from that width upward.
Any responsive utility accepts one scalar value or an object keyed by a configured breakpoint. The default scale is sm at 40rem, md at 48rem, lg at 64rem, xl at 80rem, and 2xl at 96rem.
Overview
Activity
import { Box, Grid, GridItem, Text } from "@smoothie-framework/whisk-react";
export function OverviewGrid() {
return (
<Grid columns={{ base: 1, md: 2 }} gap={{ base: 3, md: 5 }}>
<GridItem>
<Box background="surface2" rounded="lg" padding={4}>
<Text>Overview</Text>
</Box>
</GridItem>
<GridItem>
<Box background="surface2" rounded="lg" padding={4}>
<Text>Activity</Text>
</Box>
</GridItem>
</Grid>
);
}Sparse values
Arrays follow the configured breakpoint order: base, sm, md, lg, xl, and 2xl.
Full width at base, prose width from md.
import { Box, Text } from "@smoothie-framework/whisk-react";
export function ReadingWidth() {
return (
<Box width={["full", undefined, "prose"]} background="surface2" rounded="lg" padding={4}>
<Text>Full width at base, prose width from md.</Text>
</Box>
);
}Use an explicit undefined entry to skip a breakpoint. Prefer an object when its named keys make the change easier to review.
See Breakpoints for the configured scale and how to customize it.
Ranges
Responsive objects also accept range conditions such as mdOnly, mdDown, and mdToXl.
Shown below md and from lg upward.
import { Box, Text } from "@smoothie-framework/whisk-react";
export function CompactNotice() {
return (
<Box
display={{ base: "block", mdOnly: "none", lg: "block" }}
background="surface2"
rounded="lg"
padding={4}
>
<Text>Shown below md and from lg upward.</Text>
</Box>
);
}Visibility
Visibility helpers remove content from the rendered layout at the selected range.
import { Button, StackRow } from "@smoothie-framework/whisk-react";
export function ResponsiveActions() {
return (
<StackRow gap={3}>
<Button hideBelow="md">Desktop action</Button>
<Button hideFrom="md" variant="secondary">Compact action</Button>
</StackRow>
);
}Use hideFrom and hideBelow for an equivalent alternative or nonessential content. Do not hide the only path to information or an action.