Content · Gutenberg
Spoiler / Reveal block for WordPress
Hide content behind a click-to-reveal button. Perfect for spoilers, quiz answers, bonus tips, or any content that should stay hidden until the reader chooses to see it.
Get Blockenberg
Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.
What it actually does
Hide content behind a click-to-reveal button. Perfect for spoilers, quiz answers, bonus tips, or any content that should stay hidden until the reader chooses to see it.
Inspector panels on this block: Content, Display, Sizing. Those titles come from index.js, not from a shared template.
Behavior controls: “Spoiler type (preset colors)” options: Warning (amber), Info (blue), Danger (red), Success (green), Neutral (gray).
Where to find it
Gutenberg inserter → Content → search “Spoiler / Reveal” (block name `blockenberg/spoiler` in block.json). Style it in the sidebar after insert.
How to use Spoiler / Reveal block for WordPress
- Install Blockenberg. Install from WordPress.org and activate the plugin.
- Insert the block. Edit a page, click +, search for “Spoiler / Reveal”, insert it. Category: Content.
- Configure inspector controls that exist on this block. Open Content. Set “Header Background”, “Header Text”, “Colors — Border”, “Button Background”.
- Check the published page. The view script reads HTML data attributes: data-opts. The block editor preview may not run the same view script.
Inspector controls from this block’s code
| Control | What the code does |
|---|---|
| Header Background | Color control in the inspector. block.json default: #fffbeb. Saved as `labelBg`. |
| Header Text | Color control in the inspector. block.json default: #92400e. Saved as `labelColor`. |
| Colors — Border | Color control in the inspector. block.json default: #f59e0b. Saved as `borderColor`. |
| Button Background | Color control in the inspector. block.json default: #f59e0b. Saved as `btnBg`. |
| Button Text | Color control in the inspector. block.json default: #ffffff. Saved as `btnColor`. |
| Content Background | Color control in the inspector. block.json default: #ffffff. Saved as `contentBg`. |
| Content Text | Color control in the inspector. block.json default: #374151. Saved as `contentColor`. |
| Header Label | Text field in the inspector. block.json default: ⚠ Spoiler Warning. Saved as `label`. |
| Show Sub-label | On/off toggle in the inspector. On by default. Saved as `showSubLabel`. |
| Sub-label text | Text field in the inspector. block.json default: Click to reveal. Saved as `subLabel`. |
| Reveal button text | Text field in the inspector. block.json default: Reveal Spoiler. Saved as `revealBtnText`. |
| Hide button text | Text field in the inspector. block.json default: Hide Spoiler. Saved as `hideBtnText`. |
| Spoiler type (preset colors) | Select control; the chosen value is saved on the block. Options: Warning (amber); Info (blue); Danger (red); Success (green); Neutral (gray); Custom colors. block.json default: warning. Saved as `spoilerType`. |
| Show icon | On/off toggle in the inspector. On by default. Saved as `showIcon`. |
| ☛ Start open in editor | On/off toggle in the inspector. Off by default. Saved as `startOpen`. |
| Max width (px) | Numeric range control in the inspector. Range 300–1200. block.json default: 720. Saved as `maxWidth`. |
| Padding V (px) | Numeric range control in the inspector. Range 8–60. block.json default: 20. Saved as `paddingV`. |
| Padding H (px) | Numeric range control in the inspector. Range 8–80. block.json default: 24. Saved as `paddingH`. |
| Card radius (px) | Numeric range control in the inspector. Range 0–32. block.json default: 12. Saved as `cardRadius`. |
| Button radius (px) | Numeric range control in the inspector. Range 0–50. block.json default: 8. Saved as `btnRadius`. |
What the front-end script actually does
- The view script reads HTML data attributes: data-opts.
When this is the right block
- Hide content behind a click-to-reveal button. Perfect for spoilers, quiz answers, bonus tips, or any content that should stay hidden until the reader chooses to see it — that is the job of Spoiler / Reveal, not a generic content block.
- Use it when you need the editor control labeled “Header Background”, which exists on this block’s inspector.
- It matches pages about spoiler, reveal, hidden.
- Inserter grouping: articles, cards, lists, and long-form layouts.
Notes from the implementation
viewScript: this folder’s frontend.js is enqueued on the front end for this block.
FAQ
How do I add the Spoiler / Reveal block in WordPress?
Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “Spoiler / Reveal”. It sits under Content. After insert, open Content and set “Header Background”, “Header Text”, “Colors — Border”, “Button Background”.
What makes Spoiler / Reveal different from other Blockenberg blocks?
Hide content behind a click-to-reveal button. Perfect for spoilers, quiz answers, bonus tips, or any content that should stay hidden until the reader chooses to see it. Inspector labels on this block include “Header Background”, “Header Text”, “Colors — Border”, “Button Background”.
Is the Spoiler / Reveal Gutenberg block free?
Yes. Spoiler / Reveal ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.
Can I style Spoiler / Reveal to match my theme?
Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Content, Display, Sizing).
Related content blocks
Accordion
Collapsible accordion panels for FAQ, features, and more.
Toggle / Read More
A single expandable panel for 'Read More', spoilers, or collapsible content sections.
Content Switcher
Two-panel toggle block — a pill/tab switch with a label for each state, each panel containing its own headline, body text, bullet list, image, and CTA. Great for Individual/Team, Starter/Pro, Before/After content.
Content Warning
Editorial content advisory or sensitivity notice, optionally collapsible.
Icon Accordion
Visually rich accordion with per-item icons, badges and custom colours — great for FAQs, feature lists and onboarding flows.
Accordion Table
A data table where each row expands on click to reveal rich detail content — specs, bullet points, sub-data, or notes. Perfect for pricing tiers, product specs, API docs, and comparison matrices.
Get Blockenberg
Install Blockenberg from WordPress.org, then insert Spoiler / Reveal from the Gutenberg inserter.