Configure Text

Control the fonts and default styling of the Text tool with config.text. The font list drives every font-family picker; the default* values seed each new text block; presets defines the style grid; and min/maxFontSize bound the size input.

When to use this

  • You want on-brand typography instead of the generic system fonts.
  • You're loading custom web fonts and want them selectable in the editor.
  • You need consistent defaults (family, size, colour, weight, alignment…) for every new text block.

Configure the text tool

<ImageEditor
  src="/photo.jpg"
  config={{
    text: {
      fonts: ["Poppins", "Roboto Mono", "Playfair Display"],
      defaultFontFamily: "Poppins",
      defaultFontSize: 32,
      defaultColor: "#ffffff",
      defaultFontWeight: "normal",
      defaultFontStyle: "normal",
      defaultTextAlign: "left",
      defaultLineHeight: 1.2,
      defaultLetterSpacing: 0,
      minFontSize: 8,
      maxFontSize: 400,
      presets: [
        { id: "title", label: "Title", text: "Title", fontSizeScale: 3.75, fontWeight: "bold" },
        { id: "body", label: "Body", text: "Body text", fontSizeScale: 1 },
      ],
    },
    // Shared swatch palette for every colour picker (text, shapes, background):
    colors: ["#ffffff", "#111827", "#4f46e5", "#e11d48", "#16a34a", "#f59e0b"],
  }}
/>
OptionPurpose
fontsOrdered list shown in every font picker (previewed in their own typeface).
defaultFontFamilyFamily for new text (falls back to fonts[0]).
defaultFontSizeReference size — see the scaling note below.
defaultColorFill colour for new text.
defaultFontWeight"normal" or "bold" (a preset's own weight wins).
defaultFontStyle"normal" or "italic".
defaultTextAlign"left", "center", or "right".
defaultLineHeightLine height for new text.
defaultLetterSpacingLetter spacing (px) for new text.
minFontSize / maxFontSizeBounds for the font-size input (defaults 1 / 500).
presetsText style grid — each { id, label, text?, fontSizeScale?, fontWeight? }.
colorsTop-level (sibling of text) — swatch palette for every colour picker.

How defaultFontSize is applied

defaultFontSize is a reference size at a 1080px canvas, not a literal pixel value. The applied size is scaled to the canvas and chosen preset:

appliedSize = round(defaultFontSize × preset.fontSizeScale × min(pageW, pageH) / 1080)

So defaultFontSize: 32 on a large image with the Title preset lands well above 32px — this keeps text proportionate across image resolutions. The exact px is editable in the Text Properties panel (bounded by min/maxFontSize).

Load the matching web fonts yourself (via a <link> or @font-face) so the names you list actually render.

Try it

Open the Text tool — the style grid shows your custom presets (just Display and Caption). Add one, and the new block picks up every default below: the Playfair Display family, red fill, bold weight, italic style, and centre alignment. Open the font picker in the selection bar and it lists only your configured fonts (each previewed in its own typeface); open the colour picker and it shows just your custom colors swatches:

Loading...
Loading image...

Next steps

Verified by tests/guides/configure-fonts.spec.tsx in the @editx/image-editor package.