Hidden (Removed)
TheHidden component was removed in Material UI v7. This page documents migration paths to replace it.
Migration
The Hidden component provided two implementation modes: CSS-based and JavaScript-based. Each has a different replacement strategy.CSS implementation
Replaceimplementation="css" with the sx prop and responsive display values:
Hide on larger screens (xlUp)
Hide on smaller screens (mdDown)
Hide on specific breakpoint (only)
Hide on multiple breakpoints
JavaScript implementation
Replaceimplementation="js" with the useMediaQuery hook:
Basic usage
Hide below breakpoint
Hide specific breakpoint
Common patterns
Mobile vs Desktop content
Responsive sidebar
Responsive table vs cards
Hide AppBar title on mobile
Breakpoint reference
Material UI breakpoint values:| Breakpoint | Size | Range |
|---|---|---|
xs | Extra small | 0px - 600px |
sm | Small | 600px - 900px |
md | Medium | 900px - 1200px |
lg | Large | 1200px - 1536px |
xl | Extra large | 1536px+ |
Breakpoint helpers
up(key):@media (min-width: key)down(key):@media (max-width: key - 0.05px)between(start, end):@media (min-width: start) and (max-width: end - 0.05px)only(key):@media (min-width: key) and (max-width: next - 0.05px)not(key): Opposite ofonly
CSS vs JavaScript approaches
CSS approach (sx prop)
Pros:- Better performance (no JavaScript execution)
- Works with SSR immediately
- Simpler for basic show/hide
- No hydration issues
- Element still exists in DOM
- Takes up accessibility tree space
- Can’t prevent component mounting
JavaScript approach (useMediaQuery)
Pros:- Component doesn’t mount if hidden
- Better for expensive components
- Enables complex logic
- Requires JavaScript execution
- Can cause hydration issues
- Slight delay on initial render
Best practices
- Prefer CSS approach for simple visibility toggling
- Use JavaScript approach when preventing component mounting is important
- Consider performance - hidden elements still affect layout and accessibility
- Test on actual devices - breakpoints may not match real-world usage
- Use semantic HTML - ensure hidden content is still accessible when appropriate
Additional resources
- Box component - For responsive display utilities
- Breakpoints - Customizing breakpoint values
- The sx Prop - Using responsive values in sx prop