DocsAPI ReferencePluginsfield-google-fonts

field-google-fonts

A pre-built external field for picking a Google Font family. The stored value is the font family name (e.g. "Inter") — drop it straight into a CSS font-family declaration.

npm i @reacteditor/field-google-fonts --save

createFieldGoogleFonts

import { createFieldGoogleFonts } from "@reacteditor/field-google-fonts";
 
const config = {
  components: {
    HeadingBlock: {
      fields: {
        font: createFieldGoogleFonts(),
      },
      render: ({ font, children }) => (
        <h1 style={{ fontFamily: font }}>{children}</h1>
      ),
    },
  },
};

Without an API key the field uses a static snapshot of the full Google Fonts catalog (~1700 families). Pass apiKey to fetch the live catalog.

Options

ParamExampleDescription
apiKeyapiKey: process.env.GOOGLE_FONTS_KEYGoogle Fonts Developer API key. Optional.
familiesfamilies: [{ family: "Inter" }]Pre-supplied font list — wins over apiKey. Useful for tests or when proxying the catalog through your backend.
sortsort: "popularity""alpha" | "popularity" | "trending" | "date" | "style". Defaults to "popularity".
subsetsubset: "latin"Restrict to fonts containing this subset (e.g. "latin", "cyrillic").
placeholderplaceholder: "Pick a font"Placeholder shown when no font is selected. Defaults to "Select a Google font".
pageSizepageSize: 100Number of fonts loaded per page in the picker.
filterFieldsfilterFields: { ... }Filter UI for the picker.
initialFilters{ category: "sans-serif" }Initial filter values.