You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP →
Socket
Book a DemoInstallSign in
Socket

payload-lexical-typography

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

payload-lexical-typography

PayloadCMS lexical-editor typography extension plugin

0.5.0
latest
Source
npmnpm
Version published
Weekly downloads
556
31.13%
Maintainers
1
Weekly downloads
Ā 
Created
Source

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:

  • Install package from NPM:

    pnpm add payload-lexical-typography
    # OR
    npm install payload-lexical-typography
    
  • 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(),
        ];
      },
    });
    
  • 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

OptionTypeDefaultDescription
colorsArray<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.
colorPickerbooleantrueBy setting this to false, you can hide the color picker, limiting users to selecting only from the predefined colors.
listViewbooleanundefinedAllows you to manually switch from list to grid view and vice versa. It has higher priority than colors array type.

TextSizeFeature

OptionTypeDefaultDescription
sizesArray<{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").
scrollbooleantrueIf 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.
customSizebooleantrueBy setting this to false, you hide the custom size input field, limiting users to selecting only from the predefined size options.

TextLetterSpacingFeature

OptionTypeDefaultDescription
spacingsArray<{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").
scrollbooleantrueIf 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.
customSpacingbooleantrueBy setting this to false, you hide the custom letter spacing input field, limiting users to selecting only from the predefined spacing options.

TextLineHeightFeature

OptionTypeDefaultDescription
lineHeightsArray<{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").
scrollbooleantrueIf 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.
customLineHeightbooleantrueBy 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.

OptionTypeDefaultDescription
fontFamiliesArray<{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").
scrollbooleantrueIf 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.
customFontFamilybooleantrueBy 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

OptionTypeDefaultDescription
hideAttributionbooleanfalseControls 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 adrianmaj1122@gmail.com, 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!

Keywords

payload

FAQs

Package last updated on 30 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.