Spoiler
The Spoiler component automatically collapses content that exceeds a specified height, providing a show/hide toggle to reveal the full content.
Examples
(6)Properties
(30)Playground
Basic Usage
Set
maxHeight to reveal a preview of long copy while the rest stays accessible behind the built-in toggle.Initial State
Flip the
initiallyOpen prop to choose whether content renders expanded on mount or waits for user interaction.Max Heights
Dial the
maxHeight value up or down to control how much content stays visible before the toggle appears.Custom Control
Use the
renderControl callback alongside opened and onToggle to drive expansion with your own button or analytics hooks.Control customization
controlProps accepts any <Text> props (ff, weight, tracking, uppercase, size, color) and applies them to the show/hide control text — useful when the rest of your design system uses a particular weight or tracking style.Newspaper
Combine imagery with long-form copy to mimic a newspaper-style reveal where the reader can expand to see the full story.
Scan to open this page on your phonereact-ui-library.com/components/Spoiler
</>
react-ui-library
100+ accessible, themeable components that work seamlessly across iOS, Android, and Web.
A Platform Blocks product.
Quick Links
Resources