Skip to content
+

Display

Quickly and responsively toggle the display, overflow, visibility, and more with the display utilities.

Examples

Inline

inline
inline
import Box from '@mui/material/Box';

export default function Inline() {
  return (
    <div style={{ width: '100%' }}>
      <Box
        component="div"
        sx={(theme) => ({
          display: 'inline',
          p: 1,
          m: 1,
          bgcolor: '#fff',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        inline
      </Box>
      <Box
        component="div"
        sx={(theme) => ({
          display: 'inline',
          p: 1,
          m: 1,
          bgcolor: '#fff',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        inline
      </Box>
    </div>
  );
}
<Box component="div" sx={{ display: 'inline' }}>inline</Box>
<Box component="div" sx={{ display: 'inline' }}>inline</Box>

Block

blockblock
import Box from '@mui/material/Box';

export default function Block() {
  return (
    <div style={{ width: '100%' }}>
      <Box
        component="span"
        sx={(theme) => ({
          display: 'block',
          p: 1,
          m: 1,
          bgcolor: '#fff',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        block
      </Box>
      <Box
        component="span"
        sx={(theme) => ({
          display: 'block',
          p: 1,
          m: 1,
          bgcolor: '#fff',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        block
      </Box>
    </div>
  );
}
<Box component="span" sx={{ display: 'block' }}>block</Box>
<Box component="span" sx={{ display: 'block' }}>block</Box>

Hiding elements

For faster mobile-friendly development, use responsive display classes for showing and hiding elements by device. Avoid creating entirely different versions of the same site, instead hide element responsively for each screen size.

Screen Size Class
Hidden on all sx={{ display: 'none' }}
Hidden only on xs sx={{ display: { xs: 'none', sm: 'block' } }}
Hidden only on sm sx={{ display: { xs: 'block', sm: 'none', md: 'block' } }}
Hidden only on md sx={{ display: { xs: 'block', md: 'none', lg: 'block' } }}
Hidden only on lg sx={{ display: { xs: 'block', lg: 'none', xl: 'block' } }}
Hidden only on xl sx={{ display: { xs: 'block', xl: 'none' } }}
Visible only on xs sx={{ display: { xs: 'block', sm: 'none' } }}
Visible only on sm sx={{ display: { xs: 'none', sm: 'block', md: 'none' } }}
Visible only on md sx={{ display: { xs: 'none', md: 'block', lg: 'none' } }}
Visible only on lg sx={{ display: { xs: 'none', lg: 'block', xl: 'none' } }}
Visible only on xl sx={{ display: { xs: 'none', xl: 'block' } }}
hide on screens wider than md
hide on screens smaller than md
import Box from '@mui/material/Box';

export default function Hiding() {
  return (
    <div style={{ width: '100%' }}>
      <Box
        sx={{
          display: { xs: 'block', md: 'none' },
          m: 1,
          fontSize: '0.875rem',
          fontWeight: '700',
        }}
      >
        hide on screens wider than md
      </Box>
      <Box
        sx={{
          display: { xs: 'none', md: 'block' },
          m: 1,
          fontSize: '0.875rem',
          fontWeight: '700',
        }}
      >
        hide on screens smaller than md
      </Box>
    </div>
  );
}
<Box sx={{ display: { xs: 'block', md: 'none' }}}>
  hide on screens wider than md
</Box>
<Box sx={{ display: { xs: 'none', md: 'block' }}}>
  hide on screens smaller than md
</Box>

Display in print

Screen Only (Hide on print only)
Print Only (Hide on screen only)
import Box from '@mui/material/Box';

export default function Print() {
  return (
    <div style={{ width: '100%' }}>
      <Box
        sx={{
          display: 'block',
          displayPrint: 'none',
          m: 1,
          fontSize: '0.875rem',
          fontWeight: '700',
        }}
      >
        Screen Only (Hide on print only)
      </Box>
      <Box
        sx={{
          display: 'none',
          displayPrint: 'block',
          m: 1,
          fontSize: '0.875rem',
          fontWeight: '700',
        }}
      >
        Print Only (Hide on screen only)
      </Box>
    </div>
  );
}
<Box sx={{ display: 'block', displayPrint: 'none' }}>
  Screen Only (Hide on print only)
</Box>
<Box sx={{ display: 'none', displayPrint: 'block' }}>
  Print Only (Hide on screen only)
</Box>

Overflow

Not scrollable, overflow is hidden
Try scrolling this overflow auto box
import Box from '@mui/material/Box';

export default function Overflow() {
  return (
    <div style={{ width: 200, whiteSpace: 'nowrap' }}>
      <Box
        component="div"
        sx={(theme) => ({
          overflow: 'hidden',
          my: 2,
          p: 1,
          bgcolor: 'grey.100',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        Not scrollable, overflow is hidden
      </Box>
      <Box
        component="div"
        sx={(theme) => ({
          overflow: 'auto',
          my: 2,
          p: 1,
          bgcolor: 'grey.100',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        Try scrolling this overflow auto box
      </Box>
    </div>
  );
}
<Box component="div" sx={{ overflow: 'hidden' }}>
  Not scrollable, overflow is hidden
</Box>
<Box component="div" sx={{ overflow: 'auto' }}>
  Try scrolling this overflow auto box
</Box>

Text overflow

Lorem Ipsum is simply dummy text
Lorem Ipsum is simply dummy text
import Box from '@mui/material/Box';

export default function TextOverflow() {
  return (
    <div style={{ width: 200, whiteSpace: 'nowrap' }}>
      <Box
        component="div"
        sx={(theme) => ({
          textOverflow: 'clip',
          overflow: 'hidden',
          my: 2,
          p: 1,
          bgcolor: 'grey.100',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        Lorem Ipsum is simply dummy text
      </Box>
      <Box
        component="div"
        sx={(theme) => ({
          textOverflow: 'ellipsis',
          overflow: 'hidden',
          my: 2,
          p: 1,
          bgcolor: 'grey.100',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        Lorem Ipsum is simply dummy text
      </Box>
    </div>
  );
}
<Box component="div" sx={{ textOverflow: 'clip' }}>
  Lorem Ipsum is simply dummy text
</Box>
<Box component="div" sx={{ textOverflow: 'ellipsis' }}>
  Lorem Ipsum is simply dummy text
</Box>

Visibility

Visible containerInvisible container
import Box from '@mui/material/Box';

export default function Visibility() {
  return (
    <div style={{ width: '100%' }}>
      <Box
        component="span"
        sx={(theme) => ({
          visibility: 'visible',
          my: 2,
          p: 1,
          bgcolor: 'grey.100',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        Visible container
      </Box>
      <Box
        component="span"
        sx={{ visibility: 'hidden', p: 1, m: 1, bgcolor: 'background.paper' }}
      >
        Invisible container
      </Box>
    </div>
  );
}
<Box component="div" sx={{ visibility: 'visible' }}>
  Visible container
</Box>
<Box component="div" sx={{ visibility: 'hidden' }}>
  Invisible container
</Box>

White space

Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
import Box from '@mui/material/Box';

export default function WhiteSpace() {
  return (
    <div style={{ width: 200 }}>
      <Box
        component="div"
        sx={(theme) => ({
          whiteSpace: 'nowrap',
          overflowX: 'auto',
          my: 2,
          p: 1,
          bgcolor: 'grey.100',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        Lorem Ipsum has been the industry&apos;s standard dummy text ever since the
        1500s.
      </Box>
      <Box
        component="div"
        sx={(theme) => ({
          whiteSpace: 'normal',
          my: 2,
          p: 1,
          bgcolor: 'grey.100',
          color: 'grey.800',
          border: '1px solid',
          borderColor: 'grey.300',
          borderRadius: 2,
          fontSize: '0.875rem',
          fontWeight: '700',
          ...theme.applyStyles('dark', {
            bgcolor: '#101010',
            color: 'grey.300',
            borderColor: 'grey.800',
          }),
        })}
      >
        Lorem Ipsum has been the industry&apos;s standard dummy text ever since the
        1500s.
      </Box>
    </div>
  );
}
<Box component="div" sx={{ whiteSpace: 'nowrap' }}>
  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</Box>
<Box component="div" sx={{ whiteSpace: 'normal' }}>
  Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</Box>

API

import { display } from '@mui/system';
Import name Prop CSS property Theme key
displayPrint displayPrint display none
displayRaw display display none
overflow overflow overflow none
textOverflow textOverflow text-overflow none
visibility visibility visibility none
whiteSpace whiteSpace white-space none