Responsive styles

Adapt a component's styles to the viewport width. Props such as size take a different value for each breakpoint, and your own CSS can use media queries at the same widths.

Load the default stylesheet once, before your own CSS.

Code
import '@leverui/components/styles.css';
import './app.css';
import { Box, Button } from '@leverui/components';

<Box class="content-panel">Content</Box>
<Button size={{ base: 'sm', md: 'lg' }}>Save</Button>;
Code
.content-panel {
  padding: var(--leverui-spacing-2);
}

@media (min-width: 48rem) {
  .content-panel {
    padding: var(--leverui-spacing-6);
  }
}

base applies until a later breakpoint sets another value. Button writes data-size and breakpoint attributes in server HTML, so its size applies before JavaScript runs.

BreakpointMinimum width
sm480px
md768px
lg1024px
xl1280px
2xl1536px

Widths are in rem at a 16px reference size, so browser font settings and zoom can shift a breakpoint. Button size arrays follow base, sm, md, lg, xl, 2xl order. Use null to leave a breakpoint unchanged.

Code
<Button size={['sm', null, 'lg']}>Save</Button>

For a responsive color or a custom look, use your own class and media queries. CSS outside Lever UI's layers overrides its defaults without !important.