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 live and static Plate UI setups. The server-safe kit targets paragraphs and all heading levels, with valid values 1, 1.2, 1.5, 2, and 3.
import { BaseLineHeightPlugin, PLUGINS } from 'platejs';
export const LineHeightKit = [
BaseLineHeightPlugin.configure({
inject: {
nodeProps: {
defaultNodeValue: 1.5,
validNodeValues: [1, 1.2, 1.5, 2, 3],
},
},
targetPlugins: [PLUGINS.heading, PLUGINS.paragraph],
}),
] as const;import { BaseLineHeightPlugin, PLUGINS } from 'platejs';
export const LineHeightKit = [
BaseLineHeightPlugin.configure({
inject: {
nodeProps: {
defaultNodeValue: 1.5,
validNodeValues: [1, 1.2, 1.5, 2, 3],
},
},
targetPlugins: [PLUGINS.heading, PLUGINS.paragraph],
}),
] as const;import { createEditor } from "platejs/react";
import { LineHeightKit } from "@/components/editor/line-height";
export const editor = createEditor({
plugins: [...LineHeightKit],
});import { createEditor } from "platejs/react";
import { LineHeightKit } from "@/components/editor/line-height";
export const editor = createEditor({
Install LineHeightToolbarButton separately when the editor needs a line-height control.
The dropdown 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 { BaseLineHeightPlugin, PLUGINS } from "platejs";
import { createEditor } from "platejs/react";
export const editor = createEditor({
plugins: [
BaseLineHeightPlugin.configure({
targetPlugins: [
PLUGINS.heading,
PLUGINS.paragraph,
],
inject: {
nodeProps: {
defaultNodeValue: 1.5,
validNodeValues: [1, 1.2, 1.5, 2, 3],
},
},
}),
],
});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 | Headless plugin that stores lineHeight, injects block props, and parses HTML line-height styles. |
LineHeightPlugin | platejs/react | React wrapper around BaseLineHeightPlugin. |
editor.update.lineHeight.set | platejs | Bound update method exposed by the plugin. |
LineHeightKit | Registry kit | Server-safe setup shared by live and static editors. |
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.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/react | React line-height plugin. |
BaseLineHeightPlugin | platejs | Headless line-height plugin. |
editor.update.lineHeight.set(value, options?) | platejs | Sets or clears line height on matching blocks. |
tx.lineHeight.set(value, options?) | platejs | Transaction form for a larger atomic update. |
| Option | Surface | Use |
|---|---|---|
targetPlugins | BaseLineHeightPlugin | 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 | Plate node update options for the target range and matcher. |
import { BaseLineHeightPlugin, PLUGINS } from "platejs";
import { createEditor } from "platejs/react";
export const editor = createEditor({
plugins: [
BaseLineHeightPlugin.configure({
targetPlugins: [
PLUGINS.heading,
PLUGINS.paragraph,
],
inject: {
nodeProps: {
defaultNodeValue: 1.5,
validNodeValues: [1, 1.2, 1.5, 2, 3],
},
},
}),
],
});