For an introduction and a new presentation site, see the getting started guide. This reference covers embedding, slide data, layouts, styling, and lower-level APIs.
Add a deck to React
For an existing React 19+ app:
npm i slidepig
import { Deck, defineDeck } from "slidepig";
import "slidepig/styles.css";
const deck = defineDeck({
title: "Our seed round",
backgrounds: {
night: { src: "/art/night.jpg", overlay: { color: "#000", opacity: 0.4 } },
},
media: {
demo: { kind: "video", title: "Product demo", src: "/demo.mp4" },
},
slides: [
{
id: "hello",
layout: "hero",
tone: "dark",
background: "night",
eyebrow: "Acme",
title: "Write it once.",
body: ["Read it, or present it."],
},
{
id: "product",
title: "What we built",
body: ["Slide copy is plain text; `backticks` become inline code."],
media: ["demo"],
},
],
});
export default function App() {
return <Deck deck={deck} />;
}
Deploying
A deck is data, so the same file deploys three ways.
1. Root render: the whole page is the deck
import { mountDeck } from "slidepig/client";
import "slidepig/styles.css";
import deck from "./deck";
mountDeck(document.getElementById("deck"), { deck });
A static index.html plus this file, on any host. See apps/root-render.
2. A route or component inside another app
<Deck> is an ordinary component. On a page another site owns, pass
embedded: the deck becomes a labelled region instead of rendering its own
<main>, hidden <h1> and skip link, so the host's landmarks stay valid.
import { Deck } from "slidepig";
import "slidepig/styles.css";
<main>
<h1>Our 2026 plan</h1>
<Deck deck={deck} embedded />
</main>;
All classes are prefixed sp- and the fonts, colors and box sizing are
scoped to .sp-deck, so neither side restyles the other. apps/host-page is
a working example that installs slidepig from dist/, the way npm does.
On a framework route, pass the preload hints to the router's head API:
import { Deck, getDeckPreloadLinks } from "slidepig";
import "slidepig/styles.css";
import deck from "../decks/pitch";
// TanStack Start
export const Route = createFileRoute("/pitch")({
head: () => ({ links: getDeckPreloadLinks(deck) }),
component: () => <Deck deck={deck} />,
});
Every slide is in the server-rendered HTML, so the framework's SSR,
streaming and static export work unchanged. With the Next.js App Router,
re-export the component from a file of your own that starts with
"use client". The package ships no directive, because Rollup warns about it
in every Vite app.
3. Prerendered pages, served from a Cloudflare Worker
slidepig/server renders complete documents with nothing but
renderToString, so it runs in a build script and inside a Worker alike:
import { DeckIndex } from "slidepig";
import { renderDeckDocument, renderDocument } from "slidepig/server";
// A deck page: title, description, lang and preload hints from the deck,
// markup in <div id="deck"> ready to hydrate.
renderDeckDocument({ deck }, { stylesheets, scripts });
// Any other page, e.g. a home page listing the decks. No scripts needed.
renderDocument({ title, stylesheets, body: <DeckIndex title="Decks" decks={entries} /> });
On the client, mountDeck sees the prerendered markup and hydrates it rather
than rendering again.
slidepig/site packages this
whole setup: a folder of decks becomes a home page plus one prerendered,
validated page per deck, served by a Cloudflare Worker. Start one with
npx slidepig@latest create my-decks --skill.
Slides
A slide is an object. Only id and title are required.
| Field | Purpose |
|---|---|
id |
URL hash, and the key the tuner reports |
nav |
short label for menus (defaults to title) |
eyebrow, title, body |
the copy: strings, or any React content (title stays plain text) |
layout |
a built-in layout (below), or one from deck.layouts |
tone |
light dark paper; overrides the background's tone |
density |
normal or compact; overrides the deck's density |
background |
a name from deck.backgrounds, or an inline background object |
theme, overlay, accentColor |
palette, most specific wins |
media, mediaDisplay |
ids from deck.media; { mode: "carousel" } to group them |
actions, links |
buttons that open a video, or links out |
items, itemsTitle, itemGroups |
lists for rows, timeline, case, groups |
stats |
big numbers for metric |
details |
expandable context: [{ title, text, links?, media? }] |
code |
a code listing in the media column: { filename, source } |
visual |
a component in the media column, or ({ active, presenting }) => … |
render |
a one-off layout: ({ slide, parts, active, presenting }) => … |
className, style |
classes and inline styles or CSS variables on the slide's <section> |
backgroundOptions |
backgrounds the tuner offers for this slide |
Media without a src renders a labelled placeholder, so a draft deck looks
unfinished rather than broken.
Items can name a built-in icon (link, phone, accessibility, keyboard,
play, zap, code, sliders, image, globe, users, check, chart,
lock), so deck files need no imports beyond defineDeck. Deck-level
description and accentColor feed the page head, DeckIndex and the
controls, and image becomes the link-preview image (og:image).
Built-in layouts: hero story rows timeline metric case groups
statement closing. Every one of them shows visual, code, media and
actions when a slide has them.
Share slides across decks
defineSlides(registries, slides) checks reusable slides against shared
media, theme, background, and custom-layout names. The second argument can
be an array or a named collection:
import { defineDeck, defineSlides } from "slidepig";
import type { DeckBackground, SlideOf } from "slidepig";
const backgrounds = {
paper: { color: "#faf7ef", tone: "paper" },
} satisfies Record<string, DeckBackground>;
const shared = defineSlides(
{ backgrounds },
{
opening: {
id: "opening",
title: "A useful idea.",
layout: "hero",
background: "paper",
},
},
);
const pitch = defineDeck({
title: "Partner pitch",
backgrounds,
slides: [shared.opening, { id: "next", title: "Join the pilot." }],
});
type PitchSlide = SlideOf<typeof pitch>;
export const closing: PitchSlide = { id: "closing", title: "Let us begin." };
For a shared sequence, use defineSlides({ backgrounds }, [{ ... }]) and
spread it into each deck's slides. Names are inferred only from the first
argument; a misspelled reference in the slides remains an error. Each deck
must include the registries its shared slides reference. The helper avoids
writing DeckSlide's generic parameters by hand.
Backgrounds, fades, and density
Backgrounds can own an image, a base color, a default tone, and an overlay:
backgrounds: {
scene: {
src: "/art/scene.webp",
placeholder: "/art/scene-draft.webp",
color: "#faf7ef",
tone: "paper",
overlay: { color: "#faf7ef", opacity: 0.96, fade: "left" },
},
},
fade: "left" keeps the overlay opaque at the left and fades it toward the
right; "right" reverses that direction. Omit fade, or use "none", for
the existing flat tint. The overlay's color, opacity, and fade each resolve
from the slide override, then the named theme, then the background. A slide's
tone overrides its background's tone. The background's color supplies
the solid base and --sp-paper for that slide; slide.style can override
the generated CSS properties.
Omit a background's src while final art is pending. It renders its existing
placeholder image or solid paper color, and validation reports a draft
warning. A src or placeholder URL pointing at a missing file still fails
site build validation. For planned files, prompts,
provenance, and switching to art when it arrives, use the optional
art workflow.
Set density: "compact" on a deck for smaller type and tighter spacing;
individual slides can choose "compact" or "normal". Density preserves
responsive column behavior and does not automatically shrink overflowing
content. Use fit inspection to check the rendered result.
Mix and match
Every slide can bring its own components, layout and CSS. slidepig handles navigation, presenting and the chrome, and places what you give it.
import { defineDeck } from "slidepig";
import type { DeckLayoutProps } from "slidepig";
import { Bot } from "lucide-react";
import { Globe } from "./globe"; // ships its own dependencies
import "./my-deck.css"; // scope it with [data-deck="my-deck"]
// A layout any slide can name. `parts` is the slide's content, rendered the
// way the built-in layouts use it: copy, media, items, stats, details.
function Pricing({ slide, parts }: DeckLayoutProps) {
return (
<div className="pricing">
{parts.copy}
<PriceTable plans={slide.items} />
{parts.details}
</div>
);
}
export default defineDeck({
title: "Our pitch",
image: "/og.png", // link previews
icons: { bot: <Bot size={18} /> }, // names items can use
layouts: { pricing: Pricing }, // a typo in a slide's layout is a type error
slides: [
{
id: "intro",
title: "Hello",
// Strings are paragraphs; anything else renders as given.
body: [
"Plain text, with `code`.",
<p key="more">
Or <a href="/deck.pdf">links</a> and <em>components</em>.
</p>,
],
},
{ id: "reach", title: "Global reach", layout: "metric", visual: <Globe /> },
{
id: "demo",
title: "Try it",
// A function gets live state, e.g. to pause while off-stage.
visual: ({ active, presenting }) => (
<Demo running={active || !presenting} />
),
},
{ id: "plans", title: "Plans", layout: "pricing", items: [/* … */] },
{
id: "spotlight",
title: "One more thing",
className: "spotlight", // per-slide CSS
style: { "--glow": "#ff8a3d" },
},
{
id: "custom",
title: "Anything",
// A one-off layout, with the same parts.
render: ({ parts }) => <Poster>{parts.copy}</Poster>,
},
],
});
- A layout per deck or per site.
deck.layoutsare the deck's own;<Deck layouts>(ordeckProps.layoutsinslidepig/site) adds layouts shared by several decks, and wins. A name that matches a built-in layout replaces it. - Reuse the built-ins.
builtInLayouts.storyand friends are ordinary components: wrap one to make a variant.Prose,RichText,SlideMedia,ItemGroup,StatsandActionCardsare exported for layouts of your own. - Keep it valid.
validateDeckreports layouts that do not exist.apps/demo/src/decks/mix.tsxshows all of this in one deck.
<Deck> props
| Prop | Default | |
|---|---|---|
deck |
— | from defineDeck |
resolver |
URLs as written | optimized images: createMediaResolver(manifest) |
labels |
from deck.lang |
full label set or partial override |
icons |
slideIcons |
add or replace glyphs that slide items name with icon |
layouts |
built-in | layouts slides can name, over the deck's own |
controlIcons |
built-in SVGs | replace the control bar icons |
sidebar |
false |
a fixed slide list beside the reading view |
tuner |
"localhost" |
true to ship it, false to remove it |
tunerInitiallyVisible |
false |
D toggles it either way |
slideshow |
options passed to useSlideshow |
|
controls |
props passed to SlideshowControls |
|
mediaSizes |
reading column | sizes for slide art |
embedded |
false |
a region inside a host page, not a whole page |
The deck's lang selects French controls for fr and regional variants such
as fr-CA, case-insensitively. Other languages and an omitted lang use
English. This works for standalone, embedded, and site-rendered decks;
site.lang still describes the home page. Explicit labels overrides are
merged over that language's defaults, including nested control, message,
and tuner strings. Pass englishLabels or frenchLabels to choose a complete
set explicitly. labelsForLanguage(lang) returns the same built-in default
for custom chrome.
Images
slidepig assets is an
optional build step (it needs sharp as a dev dependency) that writes AVIF/WebP
derivatives and blur placeholders and records them in a committed manifest.
The resolver that reads the manifest is part of slidepig itself, so pages
never pull the build tooling:
import { Deck, createMediaResolver } from "slidepig";
import manifest from "./generated/media-manifest.json";
<Deck deck={deck} resolver={createMediaResolver(manifest)} />;
Anything the pipeline has not processed renders from its original URL, so development never breaks.
Checking a deck
defineDeck catches typos in names at compile time. validateDeck(deck)
catches the rest at build time: duplicate or URL-unsafe slide ids,
references to missing media in untyped decks, layouts missing the field they
display, dead hash aliases, and unfinished media or background warnings.
slidepig/site runs it on every build.
import { formatDeckIssues, validateDeck } from "slidepig";
const issues = validateDeck(deck);
if (issues.some((issue) => issue.level === "error"))
throw new Error(formatDeckIssues(deck, issues));
The data type for a deck is exported as DeckData, since Deck is the
component.
Data validation cannot measure browser layout. The optional
slidepig inspect command visits every slide in presentation
mode, waits for fonts and images, and reports overflow at the viewports you
choose. It can inspect multiple deck URLs and save failure screenshots or a
JSON report. Use a built preview so hot reload does not interrupt the check;
reading-mode section heights do not establish presentation fit.
Styling
slidepig/styles.css imports three namespaced layers you can also take
separately: slidepig/controls.css, slidepig/media.css, slidepig/deck.css.
Classes are prefixed sp-; colors are custom properties on .sp-deck:
.sp-deck.sp-brand-theme {
--sp-font: Georgia, "Times New Roman", serif;
--sp-ink: #1d1a20;
--sp-muted: #5f5866;
--sp-paper: #f6f1fb;
--sp-line: #e2dbe8;
--sp-accent: #c2185b;
--sp-ui-accent: #c2185b; /* the control bar */
}
Pass className="sp-brand-theme" to <Deck>, or set
deckProps: { className: "sp-brand-theme" } in a site to share that theme.
For one site deck, [data-deck="<slug>"] .sp-deck also scopes styles: the site
puts the slug on <div id="deck">, an ancestor of the component. Embedded
decks do not receive that wrapper automatically.
--sp-font controls the deck font; its fallback is the existing Inter/system
stack. With a directional overlay, --sp-overlay-fade-start (default 0%)
and --sp-overlay-fade-end (default 75%) control the solid and transparent
stops. Set them on the scoped deck or an individual slide. They work with the
overlay API, so no pseudo-element override is needed.
For deliberate sentence breaks, keep titles as plain text and insert newlines in the deck. For controlled copy, a local recipe can split at sentence ends:
const title = "One useful thought. Another clear thought.";
const sentenceTitle = title.split(/(?<=[.!?])\s+/).join("\n");
// Use sentenceTitle as the slide title; use nav for a shorter menu label.
.sp-deck.sp-brand-theme .sp-copy h2 {
white-space: pre-line;
}
Keep such editorial choices in the deck; punctuation-based splitting needs review for abbreviations and other languages.
Going headless
Every layer is exported on its own:
| Import | Contains |
|---|---|
slidepig |
Deck, DeckIndex, defineDeck, the slide blocks, labels, tuner |
slidepig/client |
mountDeck: render or hydrate into an element |
slidepig/server |
renderDeck, renderDeckDocument, renderDocument |
slidepig/react |
useSlideshow, SlideshowControls: bring your own markup |
slidepig/media |
MediaCarousel, MediaLightbox |
slidepig/images |
createMediaResolver, manifest types |
slidepig/art |
Node-only art manifest generation, status, and prompt helpers |
slidepig/inspect |
Node-only browser fit inspection with optional Playwright |
slidepig/core |
framework-free navigation, hash and preload helpers |
import { SlideshowControls, useSlideshow } from "slidepig/react";
const slideshow = useSlideshow({ slides, inactiveSlideStrategy: "stacked" });
<div ref={slideshow.rootRef}>
{slides.map((slide, index) => (
<section key={slide.id} {...slideshow.getSlideProps(index)}>
…
</section>
))}
<SlideshowControls controller={slideshow} />
</div>;
Agent skill
The package includes a slidepig skill: reusable instructions for coding agents that create, edit, style, embed, and validate slidepig decks. Installing the library and installing the skill are separate steps; the skill adds instructions, not runtime code.
For a fresh project, npx slidepig@latest create my-decks --skill installs the
skill alongside the working example.
For an existing project, run the skills CLI from your project root:
npx skills add iplanwebsites/slidepig --skill slidepig
Choose your coding agent when prompted. The installer places the skill in
that agent's skill directory. This installs agent instructions; install the
library separately with npm install slidepig when embedding a deck in an
existing React app.
Then ask your agent:
Use $slidepig to create a product pitch in this project.
The skill also ships in the npm package. For agents without skill discovery,
point them at node_modules/slidepig/skills/slidepig/SKILL.md explicitly.
Keep project-specific instructions in your project's agent instruction file.
License
Business Source License 1.1. Copyright © 2026 Félix Ménard.
Free to read, modify and share, and free in production for your own presentations and for presentations you build for clients. Not permitted: offering slidepig, or anything built with it, as a way for others to make presentations. That covers AI agents and generators, hosted builders, and reselling it or kits built on it. Each version becomes open source under MPL-2.0 four years after its release. For other arrangements, contact the author.