Embedding Folio in your app
<FolioApp> and <SlidesApp> are complete apps. Every region in them (the app bar, the toolbar or ribbon and each of its groups, the left rail, the inspector and each panel, the status bar, the notes, the canvas, the menus) is also a public component that works on its own. A host such as a university portal can place a few of these pieces inside its own header, sidebar and pages, and style them with its own design system. This guide covers:
- composing the pieces region by region;
- the token contract and the host theming adapter;
unstyledmode;- turning features off.
1. Compose region by region
Slides
The slide pieces read the deck from <DeckProvider>. Wrap the pieces you place in <SlidesRoot>. It adds the classes the CSS and tokens hang on, the CSS itself (once, unless you pass unstyled), and the feature switches. It sets no size or layout, so the pieces sit wherever your layout puts them.
import { FolioHostTheme, FolioStyles, Toolbar } from '@nextgensoftwares/folio-react';
import { createDeckEditor } from '@nextgensoftwares/folio-slides-editor';
import { DeckProvider, SlidesRoot, SlideEditorSurface, ThumbnailList, FormatShapePanel, homeGroups, insertGroups } from '@nextgensoftwares/folio-plugin-slides';
const deck = createDeckEditor({ presentation });
export function LectureEditor() {
const groups = [...homeGroups().filter((g) => g.id === 'font'), ...insertGroups().filter((g) => g.id === 'illustrations')];
return (
<DeckProvider deck={deck} measurer={measurer}>
<FolioStyles />
<FolioHostTheme />
<SlidesRoot features={{ comments: false, present: false, ai: false }} className="grid grid-cols-[200px_1fr_280px] h-full">
<aside className="border-r"><ThumbnailList width={160} /></aside>
<main className="flex flex-col">
<Toolbar groups={groups} label="Slide tools" />
<SlideEditorSurface />
</main>
<aside className="border-l p-3"><FormatShapePanel /></aside>
</SlidesRoot>
</DeckProvider>
);
}Each region and the component that provides it:
| Region | Component |
|---|---|
| Canvas | SlideEditorSurface (also SlideCanvas for read-only drawing) |
| Left rail | ThumbnailList, OutlineView, MasterList |
| Ribbon / toolbar | SlideRibbon (whole) or any of homeGroups(), insertGroups(), designGroups(), transitionsGroups(), slideShowGroups(), reviewGroups(), viewGroups(), shapeFormatGroups()… in folio-react's Toolbar (pick groups by id); SlideToolbar for one compact row |
| Inspector panels | FormatShapePanel, SlidePanel, NotesPanel, SelectionPane, ThemePanel, CommentsPanel, AccessibilityPanel, DesignGallery |
| Notes | NotesEditor |
| Status bar | SlidesStatusBar (zoom, onZoom, views) |
| Menus | DeckMenu (a surface's items, e.g. contextMenu), DeckItems |
| Other views | SlideSorter, DeckPresenter (slide show) |
Some buttons drive the surrounding shell: "Format" opens a panel, "Notes" toggles the notes strip, "Fit" zooms to the window. These buttons hide unless you give SlidesRoot a shell (SlidesShell: openPanel, notes, setNotes, fit, and optionally hasPanel(id) for the panels you show). So a piece never shows a button that does nothing.
Every piece is tested on its own in standalone.test.tsx, with only DeckProvider and SlidesRoot around it.
Documents
The docs pieces take the editor and the plugins' UI (composePlugins(...).ui) as props. Nothing reads a hidden app context:
| Region | Component |
|---|---|
| Canvas | FolioView |
| Toolbar | FolioToolbar (whole), builtinGroups(...) in Toolbar (pick groups), FolioBubbleBar |
| Rail and inspector | FolioSlot / SlotTabs for a slot (navigation, sidebar, settings…), or FolioAppPanel for the app's panel chrome |
| Status bar | FolioAppStatusBar, ZoomControl |
| App bar | your own header; FolioAppButton, FolioAppTitle, SaveIndicator and FolioAvatars fit into it |
| Menus | ContextMenu, SlashMenu, Menu |
The canvases fill the box you give them: give SlideEditorSurface's and FolioView's container a height (a grid row, flex: 1 with min-height: 0). FolioView also takes style={{ width: '100%', height: '100%' }}.
Two worked examples in the playground put the pieces inside a made-up course portal with its own header, sidebar, serif font, 14 px radius and purple shadcn-style variables (light and dark):
/slides.html?shell=embed: canvas, thumbnails, two ribbon groups, one panel./embed.html: the document canvas, two toolbar groups, the outline panel.
2. Theme it as your app
The token contract
All of Folio's UI reads the --folio-* tokens declared on .folio-ui. The full list is in UI kit & theming. The slides app's own tokens (--fsd-bg, --fsd-panel, --fsd-fg, --fsd-accent, --fsd-line, --fsd-muted) derive from them, so mapping --folio-* restyles both apps. Slide content never takes the UI's colours: a slide is drawn in the deck's own theme.
The adapter
hostThemeCss(tokens) maps your design tokens onto Folio's:
- What it maps: each entry is a CSS value, usually a
var()of your own variable. - What it fills in: tokens you don't give are derived from the ones you do: hover and press tints, active toggles, selection, focus, and radii around
radius. - Specificity: it is scoped above Folio's own light and dark rules (
html .folio-ui.folio-ui).
<FolioHostTheme> renders that CSS. It also keeps Folio's own light/dark in step with yours (followHostTheme(isDark) watches the root element's class and data attributes).
The reader's FolioReaderShell is a .folio-ui too, so the same <FolioHostTheme> themes it (see Theming the shell). The adapter itself lives in @nextgensoftwares/folio-tokens (pure TS); folio-react re-exports it.
For shadcn/ui:
import { FolioHostTheme, SHADCN_TOKENS, SHADCN_HSL_TOKENS } from '@nextgensoftwares/folio-react';
<FolioHostTheme /> {/* Tailwind v4 shadcn: SHADCN_TOKENS, dark = <html class="dark"> */}
<FolioHostTheme tokens={SHADCN_HSL_TOKENS} /> {/* Tailwind v3 shadcn: hsl(var(--primary)) */}SHADCN_TOKENS maps:
| Folio token | Host variable |
|---|---|
bg, chrome | --background |
bg-2, canvas | --muted |
text | --foreground |
muted | --muted-foreground |
border, border-strong | --border, --input |
accent, accent-fg | --primary, --primary-foreground |
focus | --ring |
danger | --destructive |
radius | --radius |
font | --font-sans |
Any other design system works the same way:
<FolioHostTheme tokens={{ bg: 'var(--surface)', text: 'var(--ink)', accent: 'var(--brand-600)', border: 'var(--line)', radius: '4px', font: 'var(--font-body)' }}
isDark={() => document.documentElement.dataset.theme === 'dark'} />Because the values are var() references, a light/dark switch in your app restyles Folio at once, with no re-render.
Navigation lists (the book's contents panel, the reader's contents) take their size from nav-text (14px by default; headings a pixel under). Match your own sidebar with tokens={{ ...SHADCN_TOKENS, 'nav-text': '15px' }}. The rest of Folio's chrome is sized in px (13px), so a rem value here scales with your root font size while the toolbar and menus don't; give a px value unless you want the contents list to follow the root size alone.
3. Unstyled
- Per component:
SlidesApp unstyledandSlidesRoot unstyledadd no CSS. For the docs app, leave out<FolioStyles />. - For the whole page:
setFolioUnstyled(true)setsdata-folio-unstyledon<html>. Then no Folio package injects a<style>: comment cards, TOC, code block headers, file cards, the player and the reader all stay unstyled. Protection CSS (plugin-protect) still applies, because it is part of what protection does. - Class names: these stay in every mode.
- Starting point for your own stylesheet:
folioCss,@nextgensoftwares/folio-react/styles.cssandslidesCss().
4. Turn features off
Slides
Pass features to SlidesApp or SlidesRoot. Everything is on by default. Setting a feature to false removes its panel, its ribbon tab or groups, its toggles and keys, and its marks on the slide:
| Feature | What goes |
|---|---|
notes | the notes strip, the Notes panel, the notes toggles |
comments | the Comments panel, the Comment buttons, the pins on the slide |
accessibility | the Accessibility panel and the Review button |
present | the Slide Show tab, F5, the presenter |
ai | the AI menu (it also needs the ai prop) |
design | the Design tab and panel |
transitions | the Transitions tab and the slide panel's Transition section |
export | the slide panel's Save as picture |
master | the slide master view |
views | the outline, sorter and reading views |
A ribbon tab left with only its plugins' slot shows only when a plugin fills it. A group whose buttons all hid takes no room. featureTabs(tabs, features) and featurePanels(panels, features) apply the same rules to your own lists.
Documents
Document features are plugins (comments, collaboration, TOC, math, media, code, callouts, header and footer, watermark, protect…). A plugin you don't pass to createFolioApp / composePlugins contributes no button, panel or slot, and isn't imported.
What ends up in the bundle
features hides things at runtime. For a smaller bundle, import only the pieces you use. The packages are side-effect free, so a bundler drops the rest. embed-bundle.test.ts builds the smallest editor (DeckProvider, SlidesRoot, SlideEditorSurface, ThumbnailList) and checks that none of these are in it:
- the shell, the ribbon and the panels;
- comments, AI, the presenter, image export and the accessibility checker;
- pptx/docx, motion and collaboration.
The size tests build each entry the way a Vite app's production build does (Rollup, then gzip) and enforce a budget on what loads up front. Run pnpm --filter @nextgensoftwares/folio-plugin-slides size (or folio-react, folio-reader) to see the numbers, the packages in each bundle and its lazy chunks. Add --tree for the largest files and --why <path> to see which import brings a file in.
| Entry | gzip, up front |
|---|---|
Slides viewer (SlideDeck, SlideCanvas, Thumbnails, Presenter) | 91.9 KB |
| Minimal slides editor (above) | 253.9 KB |
SlidesApp | 288.0 KB |
Docs embed (FolioStyles, FolioView, FolioEditor) | 130.8 KB |
FolioApp | 190.0 KB |
Reader shell (FolioReaderShell) | 33.3 KB |
Lazy chunks
Code that only some pages or some moments need is split into chunks that load on demand. Your bundler emits them next to your bundle; serve them from the same place, with nothing to configure. Each is either fetched when the page is idle after first paint (so its first use doesn't wait) or fetched as soon as the document or deck needs it:
| Chunk | What's in it | Loads |
|---|---|---|
shape-defs (~29 KB) | the ECMA-376 preset shape library | when a deck uses a preset beyond the core ones (its slides repaint when it lands), or the shape gallery, adjust handles or connectors need it |
warp-defs (~3 KB) | WordArt's preset text warps | when a deck has WordArt (usesTextWarps); exportSlidesPdf and image export wait for it |
student (~4.5 KB) | the slide viewer's watermark, copy/print deterrents and selectable text | during SlideDeck's first render with watermark, protect, highlights, onSelectText or selectableText |
tooltip-dom (~2 KB) | the tooltip element, its styles and placement | prefetched when the browser is idle; a first hover loads it inside the show delay |
find-ui (~7 KB) | the document find bar and its controller | the first Ctrl/⌘+F, Ctrl+H or F3 |
chrome (~3 KB) | focus mode's dim layer, focus bar and reading bar | when focus mode first turns on |
CleanupForm (~2.5 KB) | the Clean up formatting form | when its dropdown first opens |
DocumentPanelBody (~1 KB) | FolioApp's Document panel fields | when the Document tab first shows |
MobileBar (~10 KB in an embed) | the phone layout's bottom bar and the formatting toolbar it brings | when a view first goes to its phone layout |
ExportDialog, ClipboardToast (~1.5 KB) | the export / import progress dialog and the long copy and paste toast | when the first export, import or long copy or paste starts |
pdf-painters, docx-painters (layers, ~3.5 KB) | drawings, page backgrounds and borders for PDF and DOCX export | when the first PDF or DOCX is written |
math-form | the slides equation editor and plugin-math's symbol palette (mathSlidesPlugin) | when the Equation dropdown first opens |
FormatPanel, SelectionPane (layers) | the drawing format panel and selection pane | when first shown |
EditPointsLayer, ConnectorLayer, DrawLayer | the slide editor's tool overlays | while their tool (or a selected connector) is in use; prefetched when idle |
DeckFindBar, Presenter, SlideSorter, OutlineView, MasterList, the inspector panels | SlidesApp's find bar, slide show, views, master view and inspector tabs | on first use; prefetched when idle |
AiMenuPanel, TableStyles | the slides AI menu and the ribbon's table style gallery | the AI menu when the host passes ai; the gallery when its menu first opens |
FileMenu, @nextgensoftwares/folio-pptx | SlidesApp's File menu and the .pptx reader and writer behind pptxFile() | the menu with <SlidesApp file>; folio-pptx on the first open or save |
parts (reader) | the reader shell's find bar and controller and its focus bar | when find or focus mode first opens |
Tests that render these parts synchronously can load them first: preloadTooltips(), loadPresetShapes(), loadTextWarps(), or a lazy component's .preload(). Your own optional parts can use the same helpers: lazyComponent(() => import('./Panel').then((m) => m.Panel)) and preloadWhenIdle(...) from folio-react.
The "Made with Folio" credit
FolioApp, FolioBookApp and SlidesApp (at the end of the app bar), the slide viewer (SlideDeck, in its bar) and the reader shell (at the end of its toolbar) show a small "Made with Folio" link (Arabic: "صُنع باستخدام Folio") to https://folio.nextgen-softwares.com, opening in a new tab. It shrinks to Folio's mark on narrow screens and is hidden in focus mode, the slide show and print. The apps' creditPlacement="statusBar" moves it to the end of the status bar instead. When the bar is rendered into your header with appBarTarget, the credit stays in Folio's own chrome by default (the status bar, or a slim bar of its own), not your header; only an explicit creditPlacement="appBar" puts it at the end of the portaled bar (still Folio's own markup). With no app bar (appBar={false}, or a slides app's bar replaced by your node) it is in the status bar, so it stays in Folio's own surface. It is always shown (with the status bar off or on a phone, in a slim bar of its own): hosts may point it elsewhere or rename it with credit={{ href, label }}, not remove it (credit={false} from older hosts is ignored). <FolioCredit> (folio-react) places it anywhere in your own layout. Exported files carry no credit on their pages, only Folio in their metadata (see Export).
The Folio mark on pages
Every page Folio draws on screen carries the same small mark (exported files don't): "Made with Folio" and Folio's folded-page logo, 6pt, in a corner of the page, in a quiet grey picked for the page it sits on so it always reads at WCAG AA (4.5:1) or better: dark ink on white or sepia paper, light ink on dark pages. It sits 10px in from the edges, clear of the text, over the content (a full-page picture or a slide background never hides it), and prints.
On screen it never renders smaller than 11px (CREDIT_MARK_MIN_PX), whatever the zoom: zoomed out, it grows from its corner, within the page's margin and clear of a header or footer beside it (creditMarkRoom; at most 30% of the page's width). Zoomed in past 137.5%, it grows with the page. DOM pages follow the zoom live through the --folio-zoom custom property Folio's views set on each page (creditMarkScaleCss), and canvas pages are drawn at the size for their zoom.
| Surface | Where |
|---|---|
Editor pages (FolioView, FolioApp) and book pages (FolioBookApp) | every page, DOM (.folio-page-credit) |
Reader (createReader, FolioReaderView, FolioReaderShell) | every page: DOM, canvas pages, prints |
| Image zoom (reader and book) | drawn on the zoomed image |
Slides (SlideDeck, SlidesApp, thumbnails, the presenter) | drawn on every slide canvas |
Exported files (PDF, Word, PowerPoint, slide pictures) don't carry it. On screen it can't be turned off (no option removes it, credit={false} is ignored). Hosts tune it through the same credit option as the credit link, within limits:
credit={{
corner: 'bottom-end', // 'bottom-end' (default) | 'bottom-start' | 'top-end' | 'top-start'; logical: end is the right, the left on right-to-left pages
tone: 'auto', // 'auto' (default: dark ink on light pages, light on dark) | 'dark' | 'light' (preferred; switched when it can't reach AA on the page)
opacity: 0.45, // strength, clamped to CREDIT_MARK_LIMITS.opacity: 0.35 (5:1 with the page) to 0.6 (7:1)
}}CREDIT_MARK_LIMITS, CREDIT_CORNERS and resolveCreditMark (folio-a11y, also re-exported by the reader) give the bounds for a settings UI. A label replaces "Made with Folio" only when it names Folio. The mark is always one solid colour (resolveCreditMark(credit, surface), creditMarkOnSurface; CREDIT_MARK_CONTRAST gives the contrast range), inked for its surface:
- Editor and book pages, reader DOM pages: the page's background as rendered (
--folio-page-bg,--fr-page, a dark document's colours or a host's own). - Canvas pages, slides, zoomed images: the pixels already painted under the mark.
Which corner is "end" follows the document's direction, by one rule on every surface (creditMarkRtl, folio-a11y), so a document's pages and its slides agree:
- the stated direction: a reader or book chapter's
dir, a right-to-left Word theme; - else most of the lines of the document's first three pages with text (a deck's first three slides with text, by each paragraph's
rtlor first strong letter): one Arabic paragraph in an English book moves nothing; - else, with no document at hand, the page's own lines.
A minimal configuration
An editor and a canvas, nothing else:
<DeckProvider deck={deck} measurer={measurer}>
<SlidesRoot features={{ notes: false, comments: false, accessibility: false, present: false, ai: false, design: false, transitions: false, master: false, views: false }}>
<SlideEditorSurface />
</SlidesRoot>
</DeckProvider>For documents:
<FolioStyles />
<FolioView editor={editor} />