<Visibility
hidden={false}
spacePreserved={false}
/>Features
- Responsive
hidecontrol. - Optimized for SSR.
- Improved performance with CSS-based hiding.
- Easy integration with other components.
- Customizable screen size breakpoints.
Hidden
When hidden is true, the element is removed from the layout with display: none. When false (the default), it renders normally.
<Stack direction="row" gap={4}>
<Placeholder width={8} height={8} />
<Visibility hidden={false}>
<Placeholder width={8} height={8} />
</Visibility>
<Placeholder width={8} height={8} />
</Stack>
<Stack direction="row" gap={4}>
<Placeholder width={8} height={8} />
<Visibility hidden>
<Placeholder width={8} height={8} />
</Visibility>
<Placeholder width={8} height={8} />
</Stack>Space Preserved
By default, hidden uses display: none and collapses the element's space. Set spacePreserved to instead use visibility: hidden, keeping the layout space intact.
<Stack direction="row" gap={4}>
<Placeholder width={8} height={8} />
<Visibility hidden>
<Placeholder width={8} height={8} />
</Visibility>
<Placeholder width={8} height={8} />
</Stack>
<Stack direction="row" gap={4}>
<Placeholder width={8} height={8} />
<Visibility hidden spacePreserved>
<Placeholder width={8} height={8} />
</Visibility>
<Placeholder width={8} height={8} />
</Stack>Responsive
hidden accepts a breakpoint object to show or hide content at different viewport sizes. Resize the viewport to see the effect.
<Visibility hidden={{ xs: false, md: true }}>
<Placeholder />
</Visibility>
<Visibility hidden={{ xs: true, md: false }}>
<Placeholder />
</Visibility>Accessibility
Both display: none and visibility: hidden hide content from assistive technologies. Use Visibility only for layout-driven show/hide — not as a substitute for proper ARIA attributes.
hidden with display: none removes the element from both layout and the accessibility tree.spacePreserved uses visibility: hidden, which also hides the element from screen readers while preserving its layout space.