logo

SINGULARITY

DOCS

PurchaseReturn to the Dashboard
Reference

Box

The Box component serves as a versatile, theme-aware container with access to MUI System's CSS utilities.

Introduction

The Box component acts as a general-purpose container for organizing other components. It’s a core element in Material UI, functioning as an enhanced <div> with built-in features like theme integration and the sx prop.

Usage

The Box component is designed for flexible, multipurpose use, similar to a <div>. Unlike other Material UI containers such as Container, Stack, and Paper, which are tailored for specific purposes (main layout orientation, one-dimensional layouts, and elevated surfaces, respectively), Box offers open-ended functionality.

Basics

import Box from '@mui/material/Box';
By default, the Box component renders as a <div>, but you can substitute it with any valid HTML tag or React component using the component prop. The example below demonstrates replacing the <div> with a <section> element:
This Box renders as an HTML section element.

Customization

With the sx prop

Leverage the sx prop to easily customize any Box instance with a comprehensive set of CSS properties, including access to MUI System’s style functions and theme-aware properties. The example below illustrates applying theme colors using this prop:

With MUI System props

MUI System props are deprecated and will be phased out in the next major release. It’s recommended to use the sx prop instead.
- <Box mt={2} />
+ <Box sx={{ mt: 2 }} />

Anatomy

The Box component consists of a single root <div> element:
<div className="MuiBox-root">
  
</div>