Disclosure›Reveal

core

Reveal

Progressive disclosure where content appears step by step

Source

import Markdoc from '@markdoc/markdoc';
import type { RenderableTreeNode } from '@markdoc/markdoc';
const { Tag } = Markdoc;
import {
	createComponentRenderable,
	createContentModelSchema,
	bodyOnly,
	asNodes,
	renderNodes,
} from '../lib/index.js';
import { RenderableNodeCursor } from '../lib/renderable.js';
import { pageSectionProperties } from './common.js';

const modeType = ['click', 'scroll', 'auto'] as const;

export const revealStep = createContentModelSchema({
	attributes: {
		name: { type: String, required: true },
	},
	contentModel: bodyOnly(),
	transform(resolved, attrs, config) {
		const nameTag = new Tag('span', {}, [attrs.name ?? '']);
		const body = renderNodes(resolved.body, config).wrap('div');

		return createComponentRenderable({
			rune: 'reveal-step',
			tag: 'div',
			properties: {
				name: nameTag,
			},
			refs: {
				body: body.tag('div'),
			},
			children: [nameTag, body.next()],
		});
	},
});

export const revealSections = {
	preamble: 'preamble',
	eyebrow: 'eyebrow',
	headline: 'title',
	blurb: 'description',
} as const;

export const reveal = createContentModelSchema({
	sections: revealSections,
	attributes: {
		mode: {
			type: String,
			required: false,
			matches: modeType.slice(),
			description: 'Step progression: click, scroll, or auto',
		},
	},
	contentModel: () => ({
		type: 'sections' as const,
		sectionHeading: 'heading',
		emitTag: 'reveal-step',
		emitAttributes: { name: '$heading' },
		fields: [
			{ name: 'header', match: 'heading|paragraph', optional: true, greedy: true },
			{ name: 'items', match: 'tag', optional: true, greedy: true },
		],
		sectionModel: {
			type: 'sequence' as const,
			fields: [{ name: 'body', match: 'any', optional: true, greedy: true }],
		},
	}),
	transform(resolved, attrs, config) {
		const headerNodes = renderNodes(resolved.header, config);
		const allItems = [...asNodes(resolved.items), ...asNodes(resolved.sections)];
		const sectionNodes = new RenderableNodeCursor(
			Markdoc.transform(allItems, config) as RenderableTreeNode[],
		);
		const modeMeta = new Tag('meta', { content: attrs.mode ?? 'click' });

		const steps = sectionNodes.tag('div').typeof('RevealStep');
		const stepsContainer = steps.wrap('div');

		const children =
			headerNodes.count() > 0
				? [headerNodes.wrap('header').next(), modeMeta, stepsContainer.next()]
				: [modeMeta, stepsContainer.next()];

		return createComponentRenderable({
			rune: 'reveal',
			tag: 'section',
			properties: {
				step: steps,
			},
			refs: { ...pageSectionProperties(headerNodes), steps: stepsContainer },
			children,
		});
	},
});

View packages/runes/src/tags/reveal.ts on GitHub

Progressive disclosure. Headings become reveal steps, with content shown one step at a time. To let the reader open any panel in any order, use accordion; for one collapsible block, use details; to switch between alternatives, use tabs.

Basic usage

Headings automatically split content into reveal steps.

{% reveal %}
### Step 1: Install the package

Run the install command to add refrakt.md to your project.

### Step 2: Configure your theme

Set up the lumina theme in your config file.

### Step 3: Write content

Create Markdown files with runes and watch them transform.
{% /reveal %}
<section data-rune="reveal">
  <meta content="click">
  <div data-name="steps">
    <div data-rune="reveal-step" data-field="step">
      <span data-field="name">Step 1: Install the package</span>
      <div data-name="body">
        <p>Run the install command to add refrakt.md to your project.</p>
      </div>
    </div>
    <div data-rune="reveal-step" data-field="step">
      <span data-field="name">Step 2: Configure your theme</span>
      <div data-name="body">
        <p>Set up the lumina theme in your config file.</p>
      </div>
    </div>
    <div data-rune="reveal-step" data-field="step">
      <span data-field="name">Step 3: Write content</span>
      <div data-name="body">
        <p>Create Markdown files with runes and watch them transform.</p>
      </div>
    </div>
  </div>
</section>
Step 1: Install the package

Run the install command to add refrakt.md to your project.

Step 2: Configure your theme

Set up the lumina theme in your config file.

Step 3: Write content

Create Markdown files with runes and watch them transform.

<section class="rf-reveal rf-reveal--click" data-mode="click" data-elevation="flat" data-rune="reveal" data-density="full">
  <meta content="click" />
  <div data-name="steps" class="rf-reveal__steps">
    <div class="rf-reveal-step" data-field="step" data-rune="reveal-step" data-density="full" data-state="closed">
      <span data-field="name">Step 1: Install the package</span>
      <div data-name="body" class="rf-reveal-step__body">
        <p>Run the install command to add refrakt.md to your project.</p>
      </div>
    </div>
    <div class="rf-reveal-step" data-field="step" data-rune="reveal-step" data-density="full" data-state="closed">
      <span data-field="name">Step 2: Configure your theme</span>
      <div data-name="body" class="rf-reveal-step__body">
        <p>Set up the lumina theme in your config file.</p>
      </div>
    </div>
    <div class="rf-reveal-step" data-field="step" data-rune="reveal-step" data-density="full" data-state="closed">
      <span data-field="name">Step 3: Write content</span>
      <div data-name="body" class="rf-reveal-step__body">
        <p>Create Markdown files with runes and watch them transform.</p>
      </div>
    </div>
  </div>
</section>

How Markdown is read

You writeIt becomes
A short paragraph, then a heading and a paragraph, before the first step headingThe eyebrow, headline and blurb (Page sections)
A headingA step's title; the content up to the next heading of the same level is the step

Attributes

AttributeTypeRequiredDescription
mode"click" | "scroll" | "auto"—Step progression: click, scroll, or auto

Universal attributes

bg

The background layer: image, video, gradient, flat overlay wash and legibility scrim, in a single injected layer behind the rune's content.

AttributeTypeRequiredDescription
bgstring—Background preset applied to this block
bg-fromstring—Gradient start colour — a semantic token name (→ var(--rf-color-*))
bg-gradient"to-t" | "to-b" | "to-l" | "to-r" | "to-tr" | "to-br" | "to-bl" | "to-tl"—Gradient direction (bounded named set)
bg-gradient-type"linear" | "radial" | "conic"—Gradient type
bg-tostring—Gradient end colour — a semantic token name
bg-viastring—Optional middle gradient stop — a semantic token name
scrim"top" | "bottom" | "left" | "right" | "none"—Scrim direction (heaviest edge); presence turns the scrim on, "none" opts out of the default cover scrim
scrim-blur"none" | "sm" | "md" | "lg"—Frost scrim blur amount
scrim-strength"sm" | "md" | "lg"—Gradient scrim strength
scrim-tone"dark" | "light"—Whether the scrim darkens (for light text) or lightens (for dark text)
scrim-type"gradient" | "frost"—Scrim treatment: gradient (default) or frost (backdrop blur)
elevation

How far the rune sits off the page, from sunken to overlay. The theme decides what each step looks like.

AttributeTypeRequiredDescription
elevation"sunken" | "flush" | "flat" | "raised" | "floating" | "overlay" | "none" | "sm" | "md" | "lg"—Surface depth, from sunken to overlay. Deprecated: none, sm, md and lg (read as flat, raised, raised and floating)
inset

Internal padding override.

AttributeTypeRequiredDescription
inset"flush" | "tight" | "default" | "loose" | "breathe"—Inner padding of this block
motion

Scroll-reveal entrance. You choose its character; the theme decides how it moves.

AttributeTypeRequiredDescription
reveal"none" | "fade" | "slide" | "scale" | "blur"—Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography
staggerboolean—Cascade this block's items in as it reveals (no-op on single-child runes)
prominence

Header emphasis. Scales a rune's header, or its featured quotation; the theme decides the type size for each step.

AttributeTypeRequiredDescription
prominence"quiet" | "normal" | "prominent" | "display" | "marquee"—Emphasis of a page-section header or a featured quotation (only on runes that have one)
spacing

Block-level rhythm override.

AttributeTypeRequiredDescription
spacing"flush" | "tight" | "default" | "loose" | "breathe"—Vertical spacing above and below this block
substrate

Generated pattern fills behind the content, drawn by the theme.

AttributeTypeRequiredDescription
substrate"dots" | "grid" | "lines" | "cross" | "checker" | "none"—Generated surface pattern
substrate-fill"inherit" | "inset"—Surface fill the pattern sits on (full colour stays with tint)
substrate-opacity"sm" | "md" | "lg"—Pattern ink strength
substrate-size"sm" | "md" | "lg"—Pattern cell size
substrate-target"self" | "media"—Which surface the pattern fills (overrides the rune/theme default)
tint

Per-rune colour override: a named tint from the theme registry, with inline per-token overrides layered on top.

AttributeTypeRequiredDescription
tintstring—Color tint preset applied to this block
tint-mode"auto" | "dark" | "light"—Whether the tint adapts to auto, dark, or light mode
width

The track a block rune occupies.

AttributeTypeRequiredDescription
width"compact" | "narrow" | "content" | "wide" | "full"—Maximum width constraint for this block
Not availableWhy
dropcap, readingthis rune declares no prose body
framethis rune declares neither a `frameTarget` nor a media section

reveal-step

AttributeTypeRequiredDescription
namestring✓

Universal attributes

bg

The background layer: image, video, gradient, flat overlay wash and legibility scrim, in a single injected layer behind the rune's content.

AttributeTypeRequiredDescription
bgstring—Background preset applied to this block
bg-fromstring—Gradient start colour — a semantic token name (→ var(--rf-color-*))
bg-gradient"to-t" | "to-b" | "to-l" | "to-r" | "to-tr" | "to-br" | "to-bl" | "to-tl"—Gradient direction (bounded named set)
bg-gradient-type"linear" | "radial" | "conic"—Gradient type
bg-tostring—Gradient end colour — a semantic token name
bg-viastring—Optional middle gradient stop — a semantic token name
scrim"top" | "bottom" | "left" | "right" | "none"—Scrim direction (heaviest edge); presence turns the scrim on, "none" opts out of the default cover scrim
scrim-blur"none" | "sm" | "md" | "lg"—Frost scrim blur amount
scrim-strength"sm" | "md" | "lg"—Gradient scrim strength
scrim-tone"dark" | "light"—Whether the scrim darkens (for light text) or lightens (for dark text)
scrim-type"gradient" | "frost"—Scrim treatment: gradient (default) or frost (backdrop blur)
elevation

How far the rune sits off the page, from sunken to overlay. The theme decides what each step looks like.

AttributeTypeRequiredDescription
elevation"sunken" | "flush" | "flat" | "raised" | "floating" | "overlay" | "none" | "sm" | "md" | "lg"—Surface depth, from sunken to overlay. Deprecated: none, sm, md and lg (read as flat, raised, raised and floating)
inset

Internal padding override.

AttributeTypeRequiredDescription
inset"flush" | "tight" | "default" | "loose" | "breathe"—Inner padding of this block
motion

Scroll-reveal entrance. You choose its character; the theme decides how it moves.

AttributeTypeRequiredDescription
reveal"none" | "fade" | "slide" | "scale" | "blur"—Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography
staggerboolean—Cascade this block's items in as it reveals (no-op on single-child runes)
spacing

Block-level rhythm override.

AttributeTypeRequiredDescription
spacing"flush" | "tight" | "default" | "loose" | "breathe"—Vertical spacing above and below this block
substrate

Generated pattern fills behind the content, drawn by the theme.

AttributeTypeRequiredDescription
substrate"dots" | "grid" | "lines" | "cross" | "checker" | "none"—Generated surface pattern
substrate-fill"inherit" | "inset"—Surface fill the pattern sits on (full colour stays with tint)
substrate-opacity"sm" | "md" | "lg"—Pattern ink strength
substrate-size"sm" | "md" | "lg"—Pattern cell size
substrate-target"self" | "media"—Which surface the pattern fills (overrides the rune/theme default)
tint

Per-rune colour override: a named tint from the theme registry, with inline per-token overrides layered on top.

AttributeTypeRequiredDescription
tintstring—Color tint preset applied to this block
tint-mode"auto" | "dark" | "light"—Whether the tint adapts to auto, dark, or light mode
width

The track a block rune occupies.

AttributeTypeRequiredDescription
width"compact" | "narrow" | "content" | "wide" | "full"—Maximum width constraint for this block
Not availableWhy
dropcap, readingthis rune declares no prose body
framethis rune declares neither a `frameTarget` nor a media section
prominencethis rune has no page-section header or featured quotation