TBX Docs
Customisation

Book config

Book-wide settings in src/book/bookConfig.json

src/book/bookConfig.json is the source of truth for textbook identity and book-wide settings. It lives under src/book/, so tbx update does not overwrite it.

tbx create writes the required fields. Edit this file to change language, type, title, or to add your own values. Import it wherever you need those values:

import bookConfig from "@/book/bookConfig.json";

Required fields

FieldDescription
bookNameDisplay title (TOC header, index.html title on create/update)
bookNameSafecamelCase id used in package.json
bookSubtitleSubtitle shown under the title
bookType"default" (print + digital) or "minimal" (print only)
bookLanguageExercise UI language: "en" or "ro"
src/book/bookConfig.json
{
  "bookName": "My Textbook",
  "bookNameSafe": "myTextbook",
  "bookSubtitle": "Year 2",
  "bookType": "default",
  "bookLanguage": "ro"
}

Optional fields wired by the template

The layout passes these to <BookProvider> when they are present. Omit them to keep the provider defaults.

FieldBookProvider propDescription
bookRatiopageRatioPage image width / height as a number. For 1448×2048 use 0.70703125 (1448 / 2048).
sidebarWidthsidebarWidthTOC sidebar width (CSS length, e.g. "17em")

Custom fields

You can add any other JSON-serializable keys and read them from the same import. Extra keys are typed as unknown, so narrow them when you use them.

src/book/bookConfig.json
{
  "bookName": "My Textbook",
  "bookNameSafe": "myTextbook",
  "bookSubtitle": "Year 2",
  "bookType": "default",
  "bookLanguage": "ro",
  "publisher": "Editura XYZ"
}
src/ui/Credits.tsx
import bookConfig from "@/book/bookConfig.json";

const publisher = bookConfig.publisher as string;

export function Credits() {
  return <p>Published by {publisher}</p>;
}

Do not put React components, functions, or image imports here — use a TypeScript module under src/book/ instead (see hotspot icons).

Do not store secrets in this file. It is imported by the app and shipped in the client bundle.

On this page