Extending

Custom components

Any React component can be used in a story. Declare a module in the configuration:

TypeScriptrecit.config.ts
export default defineConfig({ components: "./components/index.tsx" });
Reactcomponents/index.tsx
import { useState } from "react"; export const Counter = ({ start = 0 }: { start?: number }) => { const [count, setCount] = useState(start); return ( <button onClick={() => setCount((c) => c + 1)}>Clicks: {count}</button> ); };

In a site, pass the same module in the publish section of recit.config.ts:

TypeScriptrecit.config.ts
import { defineConfig } from "recit/config"; import * as components from "./components/index.js"; export default defineConfig({ navigation: [], publish: { routePrefix: "/present", layout: "none", components }, });

Live demo

Click the deck, then use ← → · 2 slides · 00:02Open fullscreen →

Syntax

MarkdownMarkdown
:::component{name=Metric value="98 %" label="Lorem ipsum" trend="+2 pts"} :::
MDXMDX
<Counter start={1} />

Attributes and props

AttributeTypeDefaultDescription
namestring—Exported name of the component (required)
any otherstring—Passed as a prop (Markdown attributes are strings)

React is provided by the engine. Style a component with a CSS module next to it (Counter.module.css, imported as classes), or with the stylesheet of theme.customCss: utility classes are not compiled.

In other formats

FormatStatusNotes
deckAvailableRendered in slides, the presenter console and the HTML and PDF exports.
docsAvailableThrough <StoryEmbed slug="…" /> in any page of a site.
motionAvailableAnimated block in a film.
reportPlanned · P6Section of a paged report.
toonPlanned · P7Panel of a vertical strip.
bookPlanned · P8Block of a printable chapter.
Last modified on