Design tokens
NotionTokenScope makes Notion’s design tokens available to descendants and keeps them in sync as the host’s appearance changes. Pair it with the @notionhq/custom-blocks/nds.css import so the block matches the page it sits in, including dark mode and high contrast.
Theme and contrast
Use design tokens to style the block. When your code needs the current appearance, use a getter, subscription, or React hook. Theme is"light" or "dark". Contrast mode is "standard" or "high".
The getter and subscription names below are methods on customBlock. Import React hooks from @notionhq/custom-blocks/react.
Getters read the current value after initialization. Subscriptions can register earlier. They deliver the initial value once initialized, then later changes. React hooks keep components current when called inside
NotionCustomBlock.
See app context for examples and subscription cleanup.
Sizing
React blocks wrapped inNotionCustomBlock resize automatically to fit their content. In a framework-neutral frontend, call customBlock.autoResize({ target }) after initCustomBlock() resolves, passing the element whose height should drive the iframe.
Notion clamps automatically reported heights to a minimum of 100 pixels and a maximum of 10,000 pixels.
To cap automatic sizing at a shorter height, set max-height and overflow-y on #root: