` | 296ms |
Visit the [benchmark folder](https://github.com/mui/material-ui/tree/master/benchmark/browser) for a reproduction of the metrics above.
We believe that for most use cases it's fast enough, but there are simple workarounds when performance becomes critical.
For instance, when rendering a list with many items, you can use a CSS child selector to have a single "style injection" point (using d. for the wrapper and a. for each item).
### API tradeoff
MUI System's unifying `sx` prop helps to maintain the separation of concerns between CSS utilities and component business logic.
For instance, a `color` prop on a button impacts multiple states (hover, focus, etc.), and is distinct from the CSS `color` property.
Only the `Box`, `Stack`, `Typography`, and `Grid` components accept MUI System properties as props for this reason.
These components are designed to solve CSS problems—they are CSS component utilities.
## Where to use MUI System
The `sx` prop can be used in four different locations:
### Core components
All Material UI and Joy UI components support the `sx` prop.
### Box
[`Box`](/system/react-box/) is a lightweight component that gives access to the `sx` prop, and can be used as a utility component, and as a wrapper for other components.
It renders a `` element by default.
### Custom components
In addition to MUI System components, you can add the `sx` prop to your custom components too, by using the `styled` utility from `@mui/material/styles`.
```jsx
import { styled } from '@mui/material/styles';
const Div = styled('div')``;
```
### Any element with the babel plugin
Visit [the open GitHub issue](https://github.com/mui/material-ui/issues/23220) regarding this topic to learn more.
## How to use MUI System
### Design tokens in the theme
Visit the [System properties page](/system/properties/) to learn how the different CSS (and custom) properties are mapped to the theme keys.
### Shorthands
There are many shorthands available for various CSS properties.
These are documented on their respective Style utilities pages.
Here is an example of a few:
```jsx
```
These shorthands are optional—they're great for saving time, but not necessary to use
### Superset of CSS
The `sx` prop supports CSS syntax including child and pseudo-selectors, media queries, raw CSS values, and more.
Here are a few examples of how you can implement these CSS features:
- Using pseudo-selectors:
```jsx
```
- Using media queries:
```jsx
```
- Using nested selector:
```jsx
```
### Responsive values
The `sx` prop simplifies the process of defining and implementing responsive breakpoints.
You can define a set of breakpoints in two different ways: as an object, or as an array.
#### Breakpoints as an object
The first option for breakpoints is to define them as an object, using the breakpoint values as keys.
Note that each property for a given breakpoint also applies to all larger breakpoints in the set.
For example, `width: { lg: 100 }` is equivalent to `theme.breakpoints.up('lg')`.
The following demo shows how to define a set of breakpoints using the object syntax:
{{"demo": "BreakpointsAsObject.js"}}
:::info
📣 Starting from v6, the object structure supports [container queries](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries) shorthand with `@`.
We recommend you to check the [browser support](https://caniuse.com/?search=container%20que) before using CSS container queries.
:::
The shorthand syntax is `@{breakpoint}/{container}`:
- **breakpoint**: a number for `px` unit or a breakpoint key (e.g. `sm`, `md`, `lg`, `xl` for default breakpoints) or a valid CSS value (e.g. `40em`).
- **container** (optional): the name of the [containment context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries#naming_containment_contexts).
{{"demo": "ContainerQueries.js"}}
#### Breakpoints as an array
The second option is to define your breakpoints as an array, from smallest to largest.
Here's what that looks like:
{{"demo": "BreakpointsAsArray.js"}}
:::success
This option should only be considered when the theme has a limited number of breakpoints, for example 3.
We recommend using the object API instead if you need to define more than a few breakpoints.
:::
You can skip breakpoints with the `null` value:
```jsx
This box has a responsive width.
```
#### Custom breakpoints
You can also specify your own custom breakpoints, and use them as keys when defining the breakpoints object.
Here is an example of how to do that:
```jsx
import * as React from 'react';
import Box from '@mui/material/Box';
import { createTheme, ThemeProvider } from '@mui/material/styles';
const theme = createTheme({
breakpoints: {
values: {
mobile: 0,
tablet: 640,
laptop: 1024,
desktop: 1280,
},
},
});
export default function CustomBreakpoints() {
return (
This box has a responsive width
);
}
```
If you are using TypeScript, you will also need to use [module augmentation](/material-ui/guides/typescript/#customization-of-theme) for the theme to accept the above values.
```ts
declare module '@mui/material/styles' {
interface BreakpointOverrides {
xs: false; // removes the `xs` breakpoint
sm: false;
md: false;
lg: false;
xl: false;
tablet: true; // adds the `tablet` breakpoint
laptop: true;
desktop: true;
}
}
```
#### Theme getter
If you wish to use the theme for a CSS property that is not supported natively by MUI System, then you can use a function as the value, in which you can access the theme object.
The following demo shows how this works:
{{"demo": "ValueAsFunction.js"}}