LineHeightPlugin stores line height on blocks with a lineHeight property. Setting the default value removes the property, so saved values only carry overrides.
Use LineHeightKit for the Plate UI setup. It targets paragraphs and all heading levels, with valid values 1, 1.2, 1.5, 2, and 3.
'use client';
import { LineHeightPlugin } from '@platejs/basic-styles/react';
import { PLUGINS } from 'platejs';
export const LineHeightKit = [
LineHeightPlugin.configure({
inject: {
nodeProps: {
defaultNodeValue: 1.5,
validNodeValues: [1, 1.2, 1.5, 2, 3],
},
},
targetPlugins: [PLUGINS.heading, PLUGINS.paragraph],
}),
];'use client';
import { LineHeightPlugin } from '@platejs/basic-styles/react';
import { PLUGINS } from 'platejs';
export const LineHeightKit = [
LineHeightPlugin.configure({
inject: {
nodeProps: {
defaultNodeValue: 1.5,
validNodeValues: [1, 1.2, 1.5, 2, 3],
},
},
targetPlugins: [PLUGINS.heading, PLUGINS.paragraph],
}),
];import { createPlateEditor } from "platejs/react";
import { LineHeightKit } from "@/components/editor/line-height";
export const editor = createPlateEditor({
plugins: [...LineHeightKit],
});import { createPlateEditor } from "platejs/react";
import { LineHeightKit } from "@/components/editor/line-height";
export const editor = createPlateEditor({
LineHeightToolbarButton reads defaultNodeValue and validNodeValues from the plugin inject props.
import { LineHeightToolbarButton } from "@/components/editor/line-height-toolbar-button";
export function LineHeightControls() {
return <LineHeightToolbarButton />;
}import { LineHeightToolbarButton } from "@/components/editor/line-height-toolbar-button";
export function LineHeightControls() {
return <LineHeightToolbarButton />;
}Configure target block types and the values your UI should expose.
import { LineHeightPlugin } from "@platejs/basic-styles/react";
import { PLUGINS } from "platejs";
import { createPlateEditor } from "platejs/react";
export const editor = createPlateEditor({
plugins: [
LineHeightPlugin.configure({
targetPlugins: [
PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading,
PLUGINS.paragraph,
],
inject: {
nodeProps: {
defaultNodeValue: 1.5,
validNodeValues: [1, 1.2, 1.5, 2, 3
import { LineHeightPlugin } from "@platejs/basic-styles/react";
import { PLUGINS } from "platejs";
import { createPlateEditor } from "platejs/react";
export const editor = createPlateEditor({
plugins: [
LineHeightPlugin.configure({
targetPlugins: [
PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading,
PLUGINS.paragraph,
],
inject: {
nodeProps: {
defaultNodeValue: 1.5,
validNodeValues: [1, 1.2, 1.5
Use the bound update method.
editor.update.lineHeight.set(2);
editor.update.lineHeight.set(1.5, { at: [] });editor.update.lineHeight.set(2);
editor.update.lineHeight.set(1.5, { at: [] });| Surface | Owner | What It Does |
|---|---|---|
BaseLineHeightPlugin | @platejs/basic-styles | Headless plugin that stores lineHeight, injects block props, and parses HTML line-height styles. |
LineHeightPlugin | @platejs/basic-styles/react | React wrapper around BaseLineHeightPlugin. |
editor.update.lineHeight.set | @platejs/basic-styles | Bound update method exposed by the plugin. |
BaseLineHeightKit | Registry kit | Static/headless setup for paragraphs and headings. |
LineHeightKit | Registry kit | React setup plus toolbar dependency. |
LineHeightToolbarButton | Registry UI | Dropdown that writes values through lineHeight.set. |
The package owns line-height storage and parsing. The registry owns the dropdown UI and allowed value list.
| Behavior | Source |
|---|---|
| Plugin name | PLUGINS.lineHeight |
| Stored property | lineHeight |
| Default target plugins | [BaseParagraphPlugin] |
| Registry target plugins | [PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.heading, PLUGINS.paragraph] |
| Default node value | 1.5 |
| Registry valid values | [1, 1.2, 1.5, 2, 3] |
| HTML parser | Reads element.style.lineHeight. |
| Setting a custom value | Sets { lineHeight: value } on matching blocks. |
| Setting the default value | Unsets lineHeight on matching blocks. |
| Non-target blocks | Are ignored by lineHeight.set. |
targetPlugins is the schema placement truth. The plugin derives
its render and HTML-parser injection targets from the same list. When pasted
HTML contains an inline line-height style on a target block, Plate stores the
value on that block.
<p style="line-height: 2">Readable spacing</p><p style="line-height: 2">Readable spacing</p>| API | Package | Use |
|---|---|---|
LineHeightPlugin | @platejs/basic-styles/react | React line-height plugin. |
BaseLineHeightPlugin | @platejs/basic-styles | Headless line-height plugin. |
editor.update.lineHeight.set(value, options?) | @platejs/basic-styles | Sets or clears line height on matching blocks. |
tx.lineHeight.set(value, options?) | @platejs/basic-styles | Transaction form for a larger atomic update. |
| Option | Surface | Use |
|---|---|---|
targetPlugins | LineHeightPlugin | Element plugin descriptors or dynamic names whose nodes can keep lineHeight; injection is derived from this list. |
inject.nodeProps.defaultNodeValue | BaseLineHeightPlugin | Value that clears the stored property when selected. |
inject.nodeProps.validNodeValues | Registry toolbar | Dropdown values used by LineHeightToolbarButton. |
options | editor.update.lineHeight.set | Plite node update options for the target range and matcher. |