Skip to content

Reveal

A section that fades and settles into place as it scrolls into view.

<main class="cap-page">
  <h1>Annual report</h1>
  <p style="block-size: 30rem">Scroll down.</p>
  <section class="cap-reveal" id="rv-one">
    <h2>Twelve sites</h2>
    <p>The survey covered twelve sites along the creek.</p>
  </section>
  <div class="cap-reveal-stack" id="rv-stack">
    <h2>Four new members</h2>
    <p>Alex Rivera, Sam Lee, Jordan Park and one more joined.</p>
    <p><a href="#rv-one">Back to the sites</a></p>
  </div>
  <section class="cap-reveal" data-from="above">
    <h2>Next season</h2>
    <p>Three sites upstream.</p>
  </section>
  <p style="block-size: 30rem"></p>
</main>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/reveal.css";

Usage

<section class="cap-reveal">…</section>
<div class="cap-reveal-stack"><p>…</p><h2>…</h2><p>…</p></div>

API reference

CSS variables

VariableDefault
--reveal-distance-1.5rem

Parts and data attributes

ClassIs
.cap-revealthe root
.cap-reveal-stacka part
AttributeValues
data-fromabove

Accessibility

Nothing to reach. A revealed section's links and buttons are focusable at every moment, faded or not.