--- productId: material-ui title: React Box components: Box githubLabel: 'component: Box' githubSource: packages/mui-material/src/Box --- # Box The Box component is a generic, theme-aware container with access to CSS utilities from MUI System. {{"component": "@mui/internal-core-docs/ComponentLinkHeader", "design": false}} ## Introduction The Box component is a generic container for grouping other components. It's a fundamental building block when working with Material UI—you can think of it as a `
` with extra built-in features, like access to your app's theme and the [`sx` prop](/system/getting-started/the-sx-prop/). ### Usage The Box component differs from other containers available in Material UI in that its usage is intended to be multipurpose and open-ended, just like a `
`. Components like [Container](/material-ui/react-container/), [Stack](/material-ui/react-stack/) and [Paper](/material-ui/react-paper/), by contrast, feature usage-specific props that make them ideal for certain use cases: Container for main layout orientation, Stack for one-dimensional layouts, and Paper for elevated surfaces. ## Basics ```jsx import Box from '@mui/material/Box'; ``` The Box component renders as a `
` by default, but you can swap in any other valid HTML tag or React component using the `component` prop. The demo below replaces the `
` with a `
` element: ```tsx import Box from '@mui/material/Box'; export default function BoxBasic() { return ( This Box renders as an HTML section element. ); } ``` ## Customization Use the [`sx` prop](/system/getting-started/the-sx-prop/) to quickly customize any Box instance using a superset of CSS that has access to all the style functions and theme-aware properties exposed in the MUI System package. The demo below shows how to apply colors from the theme using this prop: ```tsx import Box from '@mui/material/Box'; import { ThemeProvider } from '@mui/material/styles'; export default function BoxSx() { return ( ); } ``` ## Anatomy The Box component is composed of a single root `
` element: ```html
``` # Box API ## Demos For examples and details on the usage of this React component, visit the component demo pages: - [Box](https://mui.com/material-ui/react-box/) - [Menubar](https://mui.com/material-ui/react-menubar/) ## Import ```jsx import Box from '@mui/material/Box'; // or import { Box } from '@mui/material'; ``` ## Props | Name | Type | Default | Required | Description | |------|------|---------|----------|-------------| | component | `elementType` | - | No | | | sx | `Array \| func \| object` | - | No | The system prop that allows defining system overrides as well as additional CSS styles. | > **Note**: The `ref` is forwarded to the root element (HTMLDivElement). > Any other props supplied will be provided to the root element (native element). ## CSS ### Rule name | Global class | Rule name | Description | |--------------|-----------|-------------| | - | root | Styles applied to the root element. | ## Source code If you did not find the information on this page, consider having a look at the implementation of the component for more detail. - [/packages/mui-material/src/Box/Box.js](https://github.com/mui/material-ui/tree/HEAD/packages/mui-material/src/Box/Box.js)