AdrianMaj

payload lexical typography

by AdrianMaj
Rich text & editors
v?
MIT

Overview

Summary generated from the README

Adds typography controls to the Payload Lexical rich text editor as individual features added to the editor config. Editors can pick predefined presets or enter custom values for each property. Converters for JSX and HTML output are imported from a separate converters submodule to render the styled text on the frontend.

Features

  • Text color with predefined palette, list or grid view, and optional color picker
  • Font size presets with optional custom size input
  • Letter spacing and line height presets with custom value inputs
  • Font family presets with optional custom font input
  • Replace or combine mode for merging custom presets with defaults
  • JSX and HTML converters for rendering styled text

Use cases

  • Give editors fine-grained text styling in Lexical fields while restricting choices to brand colors and sizes
  • Render rich text with custom fonts and spacing on a Next.js frontend using the provided converters

From the author

PayloadCMS lexical-editor typography extension plugin

Installation

npm i payload-lexical-typography

109

Stars

12

Forks

1

Open Issues

1 years ago

Last Updated

1.4k

Weekly Downloads

v0.5.2

npm Version

457.8 KB

Unpacked Size

4

Dependencies

GitHub stars

109+2 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 2026109
Dec 4, 2026109
Dec 3, 2026109
Dec 2, 2026109
Dec 1, 2026109
Nov 30, 2026109
Nov 29, 2026109
Nov 28, 2026109
Nov 27, 2026109
Nov 26, 2026109
Nov 25, 2026109
Nov 24, 2026109
Nov 23, 2026109
Nov 22, 2026109
Nov 21, 2026109
Nov 20, 2026109
Nov 19, 2026109
Nov 18, 2026109
Nov 17, 2026109
Nov 16, 2026109
Nov 15, 2026109
Nov 14, 2026109
Nov 13, 2026109
Nov 12, 2026109
Nov 11, 2026109
Nov 10, 2026109
Nov 9, 2026108
Nov 8, 2026108
Nov 7, 2026108
Nov 6, 2026108
Nov 5, 2026108
Nov 4, 2026108
Nov 3, 2026109
Nov 2, 2026109
Nov 1, 2026109
Oct 31, 2026109
Oct 30, 2026109
Oct 29, 2026109
Oct 28, 2026109
Oct 27, 2026109
Oct 26, 2026109
Oct 25, 2026109
Oct 24, 2026109
Oct 23, 2026109
Oct 22, 2026109
Oct 21, 2026108
Oct 20, 2026108
Oct 19, 2026108
Oct 18, 2026108
Oct 17, 2026108
Oct 16, 2026108
Oct 15, 2026108
Oct 14, 2026108
Oct 13, 2026108
Oct 12, 2026108
Oct 11, 2026108
Oct 10, 2026108
Oct 9, 2026108
Oct 8, 2026108
Oct 7, 2026108
Oct 6, 2026108
Oct 5, 2026108
Oct 4, 2026108
Oct 3, 2026108
Oct 2, 2026108
Oct 1, 2026108
Sep 30, 2026108
Sep 29, 2026108
Sep 28, 2026108
Sep 27, 2026108
Sep 26, 2026108
Sep 25, 2026108
Sep 24, 2026108
Sep 23, 2026108
Sep 22, 2026108
Sep 21, 2026108
Sep 20, 2026108
Sep 19, 2026108
Sep 18, 2026108
Sep 17, 2026108
Sep 16, 2026108
Sep 15, 2026108
Sep 14, 2026108
Sep 13, 2026108
Sep 12, 2026108
Sep 11, 2026108
Sep 10, 2026108
Sep 9, 2026107
Sep 8, 2026107
Sep 7, 2026107
Sep 6, 2026107
npm weekly downloads

1.3K−150 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20261,274
Dec 4, 20261,367
Dec 3, 20261,351
Dec 2, 20261,425
Dec 1, 20261,446
Nov 30, 20261,453
Nov 29, 20261,546
Nov 28, 20261,655
Nov 27, 20261,750
Nov 26, 20261,857
Nov 25, 20261,803
Nov 24, 20261,870
Nov 23, 20261,863
Nov 22, 20261,852
Nov 21, 20261,817
Nov 20, 20261,834
Nov 19, 20261,808
Nov 18, 20261,848
Nov 17, 20261,803
Nov 16, 20261,894
Nov 15, 20261,792
Nov 14, 20261,729
Nov 13, 20261,638
Nov 12, 20261,574
Nov 11, 20261,442
Nov 10, 20261,379
Nov 9, 20261,313
Nov 8, 20261,348
Nov 7, 20261,422
Nov 6, 20261,522
Nov 5, 20261,627
Nov 4, 20261,659
Nov 3, 20261,655
Nov 2, 20261,636
Nov 1, 20261,697
Oct 31, 20261,842
Oct 30, 20261,881
Oct 29, 20261,528
Oct 28, 20261,289
Oct 27, 20261,630
Oct 26, 20261,652
Oct 25, 20261,652
Oct 24, 20261,566
Oct 23, 20261,139
Oct 22, 20261,761
Oct 21, 20262,109
Oct 20, 20261,897
Oct 19, 20261,981
Oct 18, 20261,966
Oct 17, 20262,014
Oct 16, 20262,529
Oct 15, 20262,256
Oct 14, 20262,147
Oct 13, 20262,049
Oct 12, 20262,010
Oct 11, 20261,856
Oct 10, 20261,771
Oct 9, 20261,600
Oct 8, 20261,499
Oct 7, 20261,477
Oct 6, 20261,498
Oct 5, 20261,599
Oct 4, 20261,677
Oct 3, 20261,664
Oct 2, 20261,562
Oct 1, 20261,503
Sep 30, 20261,532
Sep 29, 20261,529
Sep 28, 20261,486
Sep 27, 20261,474
Sep 26, 20261,390
Sep 25, 20261,407
Sep 24, 20261,526
Sep 23, 20261,500
Sep 22, 20261,636
Sep 21, 20261,544
Sep 20, 20261,655
Sep 19, 20261,767
Sep 18, 20261,890
Sep 17, 20261,923
Sep 16, 20261,967
Sep 15, 20261,848
Sep 14, 20261,860
Sep 13, 20261,727
Sep 12, 20261,628
Sep 11, 20261,508
Sep 10, 20261,470
Sep 9, 20261,462
Sep 8, 20261,403
Sep 7, 20261,354
Sep 6, 20261,424

Each point is npm's rolling 7-day download count.

Health Score

49/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/938188280-root.svg)](https://payloaddirectory.dev/plugins/938188280-root)
HTML
<a href="https://payloaddirectory.dev/plugins/938188280-root"><img src="https://payloaddirectory.dev/badge/938188280-root.svg" alt="Payload Directory"></a>
Updated Nov 4, 2025Created Feb 24, 2025Published Nov 4, 2025

README

Payload Lexical Typography

This plugin extends the default Payload Lexical editor functionality by adding more customization options for text elements.

Core Features 🧩

  • Text color - ability to change text color to predefined colors or selected color using color picker.
  • Font size - ability to change font size to predefined sizes or custom size using input field.
  • Letter spacing - ability to change letter spacing to predefined values or custom value using input field.
  • Line height - ability to change line height to predefined values or custom value using input field.
  • Font family - ability to change font family to predefined fonts or custom font using input field.

Installation 📦

To get plugin up and running, follow these steps:

  1. Install package from NPM:

    pnpm add payload-lexical-typography
    # OR
    npm install payload-lexical-typography
    
  2. Add features you want to include in your lexical editor config, you can also pass additional props:

    import { lexicalEditor } from "@payloadcms/richtext-lexical";
    import {
      TextColorFeature,
      TextSizeFeature,
      TextLetterSpacingFeature,
      TextLineHeightFeature,
      TextFontFamilyFeature,
    } from "payload-lexical-typography";
    
    lexicalEditor({
      features: () => {
        return [
          TextColorFeature({
            colors: ["#FFFFFF", "#000000", "#FF0000", "#00FF00", "#0000FF"],
          }),
          TextSizeFeature(),
          TextLetterSpacingFeature(),
          TextLineHeightFeature(),
          TextFontFamilyFeature(),
        ];
      },
    });
    
  3. Add converters to your RichText component

    ⚠️ Warning: Starting from version 0.1.0, converters must be imported from the /converters submodule instead of /client.

    JSX Converters

    import { TypographyJSXConverters } from "payload-lexical-typography/converters";
    
    const jsxConverters: JSXConvertersFunction<NodeTypes> = ({ defaultConverters }) => ({
      ...defaultConverters,
      ...TypographyJSXConverters,
    });
    

    HTML Converters

    For HTML converter, use TypographyHTMLConverters instead of TypographyJSXConverters, from /converters submodule.

Configuration 🛠

TextColorFeature

Option Type Default Description
colors Array<string> | Array<{value: string, label: string}> [] Defines the color palette available in the color picker's predefined section. Each color should be a valid CSS color value (hex, RGB, etc.). If you pass values with label, it will automatically switch to list view instead.
colorPicker boolean true By setting this to false, you can hide the color picker, limiting users to selecting only from the predefined colors.
listView boolean undefined Allows you to manually switch from list to grid view and vice versa. It has higher priority than colors array type.

TextSizeFeature

Option Type Default Description
sizes Array<{value: string, label: string}> [] Specifies the font size presets available in the size picker. Each size needs both a display label and CSS value.
method "replace" | "combine" "replace" Determines whether custom sizes replace the defaults ("replace") or are added to them ("combine").
scroll boolean true If true, sizes over the first 4 will be accessible via scrolling within a fixed container height. If false, the picker will expand vertically to accommodate all size options.
customSize boolean true By setting this to false, you hide the custom size input field, limiting users to selecting only from the predefined size options.

TextLetterSpacingFeature

Option Type Default Description
spacings Array<{value: string, label: string}> [] Specifies the letter spacing presets available in the letter spacing picker. Each spacing needs both a display label and CSS value.
method "replace" | "combine" "replace" Determines whether custom spacings replace the defaults ("replace") or are added to them ("combine").
scroll boolean true If true, spacings over the first 4 will be accessible via scrolling within a fixed container height. If false, the picker will expand vertically to accommodate all spacing options.
customSpacing boolean true By setting this to false, you hide the custom letter spacing input field, limiting users to selecting only from the predefined spacing options.

TextLineHeightFeature

Option Type Default Description
lineHeights Array<{value: string, label: string}> [] Specifies the line height presets available in the line height picker. Each line height needs both a display label and CSS value.
method "replace" | "combine" "replace" Determines whether custom sizes replace the defaults ("replace") or are added to them ("combine").
scroll boolean true If true, line heights over the first 4 will be accessible via scrolling within a fixed container height. If false, the picker will expand vertically to accommodate all line height options.
customLineHeight boolean true By setting this to false, you hide the custom line height input field, limiting users to selecting only from the predefined line height options.

TextFontFamilyFeature

⚠️ Warning: If the fonts aren't default system fonts, you still need to import them to your project layout, if you want to see them in the editor you have to add proper @font-face rules in your custom.scss file too.

Option Type Default Description
fontFamilies Array<{value: string, label: string}> [] Specifies the font family presets available in the font family picker. Each font family needs both a display label and CSS value.
method "replace" | "combine" "replace" Determines whether custom font families replace the defaults ("replace") or are added to them ("combine").
scroll boolean true If true, font families over the first 4 will be accessible via scrolling within a fixed container height. If false, the picker will expand vertically to accommodate all font family options.
customFontFamily boolean true By setting this to false, you hide the custom font family input field, limiting users to selecting only from the predefined font family options.

Shared Options

Option Type Default Description
hideAttribution boolean false Controls visibility of attribution. If using in commercial products or for profit, consider supporting the author or keeping the attribution.

License 📜

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing 🤝

If you have any ideas on how this plugin can be improved, please feel free to open an issue or a pull request.

Contact 📧

If you have any questions, feel free to reach out to me at [email protected], or on my Linkedin profile Adrian Maj.

Support the Project

If you find this plugin useful, you can support the project by giving it a ⭐️, or buying me a coffee ☕️, for motivation to keep working on it. Thanks for your support!

Similar plugins