āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/udecode/plate/(plugins)/(elements)/heading ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
title: Heading docs:
<h1> to <h6>) by default.The fastest way to add heading plugins is with the BasicBlocksKit, which includes pre-configured H1Plugin, H2Plugin, and H3Plugin along with other basic block elements and their Plate UI components.
Add the kit to your plugins:
import { createPlateEditor } from 'platejs/react';
import { BasicBlocksKit } from '@/components/editor/plugins/basic-blocks-kit';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...BasicBlocksKit,
],
});
</Steps>
npm install @platejs/basic-nodes
Add individual heading plugins when you need more control or want to include specific heading levels.
import { createPlateEditor } from 'platejs/react';
import { H1Plugin, H2Plugin, H3Plugin } from '@platejs/basic-nodes/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
H1Plugin,
H2Plugin,
H3Plugin,
// Add H4Plugin, H5Plugin, H6Plugin as needed
],
});
Configure individual heading plugins with custom components or shortcuts.
import { createPlateEditor } from 'platejs/react';
import { H1Plugin, H2Plugin, H3Plugin } from '@platejs/basic-nodes/react';
import { H1Element, H2Element, H3Element } from '@/components/ui/heading-node';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
H1Plugin.configure({
node: { component: H1Element },
shortcuts: { toggle: { keys: 'mod+alt+1' } },
}),
H2Plugin.configure({
node: { component: H2Element },
shortcuts: { toggle: { keys: 'mod+alt+2' } },
}),
H3Plugin.configure({
node: { component: H3Element },
shortcuts: { toggle: { keys: 'mod+alt+3' } },
}),
// Configure H4Plugin, H5Plugin, H6Plugin similarly
],
});
node.component: Assigns a custom React component like H1Element to render the specific heading level.shortcuts.toggle: Defines a keyboard shortcut (e.g., mod+alt+1) to toggle the respective heading level.You can add these items to the Turn Into Toolbar Button to convert blocks into headings:
{
icon: <Heading1Icon />,
label: 'Heading 1',
value: 'h1',
}
{
icon: <Heading2Icon />,
label: 'Heading 2',
value: 'h2',
}
{
icon: <Heading3Icon />,
label: 'Heading 3',
value: 'h3',
}
You can add these items to the Insert Toolbar Button to insert heading elements:
{
icon: <Heading1Icon />,
label: 'Heading 1',
value: 'h1',
}
{
icon: <Heading2Icon />,
label: 'Heading 2',
value: 'h2',
}
{
icon: <Heading3Icon />,
label: 'Heading 3',
value: 'h3',
}
</Steps>
H1PluginPlugin for H1 heading elements.
H2PluginPlugin for H2 heading elements.
H3PluginPlugin for H3 heading elements.
H4PluginPlugin for H4 heading elements.
H5PluginPlugin for H5 heading elements.
H6PluginPlugin for H6 heading elements.
tf.h1.toggleToggles the selected block types to heading.
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā