You're reading the v2 beta docs. For the stable release, switch to v1 →
TakumiTakumi

Helpers

Build inputs and load resources without the renderer.

takumi-js/helpers re-exports @takumi-rs/helpers: functions for building the node tree and loading fonts, images, and emoji. render and ImageResponse call them for you. Reach for these only when you build inputs by hand.

Fonts

HelperUse
googleFont(family, options?)Load one Google Fonts family as fonts entries. See Fonts & text.
googleFontSubsets(source, families, options?)Load only the subsets your content needs. See Multilingual content.

Building nodes

HelperReturns
container(props)A container node.
text(text, style?) / text(props)A text node.
image(props)An image node.
style(css)The same style object, typed.

Length and color shorthands return CSS strings. vw/vh are viewport width/height, em/rem are font-relative sizes, fr is a grid fraction. See the MDN CSS values reference.

HelperOutput
percentage(50)50%
vw(100) / vh(100)100vw / 100vh
em(1.5) / rem(1.5)1.5em / 1.5rem
fr(1)1fr
rgba(0, 0, 0, 0.5)rgb(0 0 0 / 0.5)

Parsing templates

HelperImportUse
fromJsx(element, options?)takumi-js/helpers/jsxConvert JSX or a React element to { node, stylesheets }.
fromHtml(html)takumi-js/helpers/htmlConvert an HTML string to { node, stylesheets }.

Resources & emoji

HelperImportUse
extractResourceUrls(node)takumi-js/helpersCollect every image URL in a node tree.
fetchResources(urls, options?)takumi-js/helpersFetch URLs into images entries. See Images & emoji.
extractEmojis(node, emojiType)takumi-js/helpers/emojiReplace emoji with CDN <img> nodes. See Emoji.

emojiType selects the CDN provider: twemoji, blobmoji, noto, openmoji, fluent, or fluentFlat.

Edit on GitHub

Last updated on

On this page