import { Children, useEffect, useState } from 'react'; import type { SlideSyncEvent } from 'reveal.js'; import { Deck, Slide, Stack, Markdown, Fragment, Code, useReveal } from '@revealjs/react'; import 'reveal.js/reveal.css'; import 'reveal.js/theme/black.css'; import 'reveal.js/plugin/highlight/monokai.css'; import RevealHighlight from 'reveal.js/plugin/highlight'; import RevealNotes from 'reveal.js/plugin/notes'; const buttonStyle: React.CSSProperties = { padding: '0.55em 0.95em', fontSize: '0.7em', fontWeight: 600, lineHeight: 1.2, color: '#ffffff', background: 'rgba(8, 13, 24, 0.72)', border: '1px solid rgba(255, 255, 255, 0.4)', borderRadius: '0.35em', cursor: 'pointer', }; function NavigationControls() { const deck = useReveal(); return (
{' '}
); } function Columns({ children }: { children: React.ReactNode }) { return (
{Children.map(children, (child, index) => (
{child}
))}
); } function SlideSyncPlayground() { const [count, setCount] = useState(0); const [slideColor, setSlideColor] = useState('#1b1f2a'); const randomColor = () => { const value = Math.floor(Math.random() * 0xffffff) .toString(16) .padStart(6, '0'); return `#${value}`; }; return (

Slide-local HTML updates

This slide updates only its own React-rendered HTML, without manually calling{' '} sync or syncSlide.

{' '}

Current count: {count}

Slide color: {slideColor}

); } function Demo() { const [showBonus, setShowBonus] = useState(false); const [controls, setControls] = useState(true); useEffect(() => { const onKeyDown = (e: KeyboardEvent) => { if (e.key === 'c' && !e.ctrlKey && !e.metaKey && !e.altKey) { setControls((prev) => !prev); } }; window.addEventListener('keydown', onKeyDown); return () => window.removeEventListener('keydown', onKeyDown); }, []); return ( console.log('Deck ready!', deck)} onSync={() => console.log('Deck synced')} onSlideSync={(e) => { const slide = (e as SlideSyncEvent).slide; console.log('Slide synced', slide); }} onSlideChange={(e) => console.log('Slide changed')} >

@revealjs/react

React wrapper for reveal.js

Vertical Stack

Press down to navigate

{`

Vertical Stack

Press down to navigate

Stack Slide 2

Vertical navigation works!

`}

Stack Slide 2

Vertical navigation works!

API Hook

Components inside slides can access the reveal.js API via the useReveal() hook.

{` const deck = useReveal(); function nextSlide() { deck?.next(); } `}

Dynamic Slides

Add slides at runtime — sync() handles it

{showBonus && (

Bonus Slide!

Dynamically added via React state

)}

Fragments

This appears first

Then this

And this gets highlighted

{`

This appears first

Then this

And this gets highlighted

`}

Auto-animate

This slide is animated automatically

Auto-animate

Auto-animate

This slide is animated automatically

`} />

This slide is animated automatically

{` ## Markdown 1.1 - First point - Second point -- ## Markdown 1.2 Notes: These are speaker notes parsed from markdown. --- ## Markdown 2 \`\`\`js [1|2] const a = 1; const b = 2; \`\`\` `}

The End

Thanks for watching!

); } export default Demo;