@atlaskit/primitives
Version:
Primitives are token-backed low-level building blocks.
48 lines (35 loc) • 1.73 kB
text/mdx
---
title: Responsive
description: Responsive helpers and primitives to build responsive UIs.
order: 2
---
The media query helper object `media.above[breakpoint]` maps to our [breakpoints](/components/primitives/responsive/breakpoints/examples) as a media query for use in CSS-in-JS. `media.above[breakpoint]` targets all viewports **above** (larger than) the min-width of a given breakpoint
These responsive helpers are designed be used in conjunction with [xcss](/components/primitives/xcss). It is recommended that both are used when available as this uses our media queries to allow for safe, responsive styling.
Compose your default styles alongside media overrides in [xcss](/components/primitives/xcss) or `css`.
```tsx
const customStyles = xcss({
display: 'none', // hide by default
padding: 'space.100',
[]: { display: 'revert' }, // show above md
[]: { padding: 'space.150' }, // increase padding above md
});
export const Component = ({ children }: { children: ReactNode }) => (
<Box xcss={customStyles}>{children}</Box>
);
```
```tsx
const customStyles = css({
marginBlock: token('space.0'),
[]: { marginBlock: token('space.025') },
[]: { marginBlock: token('space.050') },
[]: { marginBlock: token('space.075') },
[]: { marginBlock: token('space.100') },
[]: { marginBlock: token('space.150') },
});
```
It is important to note that the `media.above.xxs` will **always** match, it is explicitly `'@media all'`. This is only included for easy programmatic usage, but it has a negative performance impact.