Docs
Font

Font

Provide extended formatting options for document content.

Add multiple font and background colors to create vibrant and eye-catching text.

Features

  • Font size, family, color, background color, and weight.

Plugins:

  • fontFamily: Change font family using inline elements with a font-family in the style attribute.
  • fontSize: Control font size with inline elements having a CSS class or a font-size in the style attribute.
  • fontColor: Control font color with inline elements having a color in the style attribute.
  • fontBackgroundColor: Control font background color with inline elements having a background-color in the style attribute.
  • fontWeight: Control font weight with inline elements having a font-weight in the style attribute.

Installation

npm install @udecode/plate-font

Usage

import {
  createFontBackgroundColorPlugin,
  createFontColorPlugin,
  createFontSizePlugin,
} from '@udecode/plate-font';
 
const plugins = [
  // ...otherPlugins,
  createFontColorPlugin(),
  createFontBackgroundColorPlugin(),
  createFontSizePlugin(),
];

API

createFontBackgroundColorPlugin

createFontColorPlugin

createFontFamilyPlugin

createFontSizePlugin

createFontWeightPlugin

API Components

useColorDropdownMenu

A behavior hook for the color dropdown menu component.

State

Collapse all

    A boolean indicating whether the dropdown menu is open.

    A callback function to toggle the open state of the dropdown menu.

Returns

Collapse all

    The props to be spread on the menu component.

    The props to be spread on the button component.

useColorInput

A behavior hook for the color input component.

Returns

Collapse all

    A ref object that should be assigned to the color input element.

    The props to be spread on the child component that triggers the color picker.

useColorsCustom

A behavior hook for custom colors in a color picker.

State

Collapse all

    The callback function to update the custom color.

    The current value of the color input.

    The callback function to update the value of the color input.

Returns

Collapse all

    The props to be spread on the color input element.

    The props to be spread on the menu item elements in the color picker.