Reveal
Reveal is a Stimulus controller that reveals elements when they enter the viewport.
Newlogic UI registers the Reveal controller from stimulus-components. It watches all elements marked as item targets and adds the data-in attribute once they become visible.
The component is usually paired with the reveal utility. The controller handles the state change, and the utility class handles the visual transition.
How It Works
- Add
data-controller="x-reveal"to the wrapper element. - Mark each element to reveal with
data-x-reveal-target="item". - When the element becomes visible in the viewport, the controller adds
data-in. - If
data-lazy-controlleris present, that controller is registered only after reveal.
Notes
- The component does not animate elements by itself.
- The visual effect is typically defined by the
revealutility. data-lazy-controlleris useful when another controller should start only after the element is visible.
Source
Example
html
<section class="grid grid-cols-container" data-controller="x-reveal">
<form data-lazy-controller="x-recaptcha">
</form>
</section>