Spoiler
Hide content until the user chooses to reveal it
Use the Spoiler
component to prevent spoilers in content like reviews or discussions or to protect sensitive information. Text wrapped in a Spoiler
component is only revealed after a click:
Tooltips
To better indicate the purpose of Spoiler
components, you can optionally add a tooltip to the element using the tooltip
prop. You can also change the positioning of the tooltip using the tooltipPosition
prop:
Inline vs Block Spoilers
By default, the Spoiler
component has its display
set to inline
to ensure each line is hidden separately. To make the element behave as a single block, you can set the block
prop to true
:
Spoiler
component into a single block, use the block
prop.Spoiler
component into a single block, use the block
prop.Styles
You can also change the style of the Spoiler
component using the color
prop:
In case you want to use a single color for all of your Spoiler
components, its recommended to set the color globally by overriding the following CSS variables:
You can also disable animations by setting the animated
prop to false
:
$disableAnimations
variable to true
in your webcore.config.scss file. API
Prop | Default | Purpose |
---|---|---|
color | var(--w-color-primary) | Sets the color of the spoiler. |
animated | true | Sets a fade animation. |
block | false | Sets the style of the spoiler to a block element. |
tooltip | - | Sets a tooltip for the spoiler. |
tooltipPosition | - | Sets the position of the tooltip. |
Request improvement for this page