āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/udecode/plate/(plugins)/(elements)/horizontal-rule ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
title: Horizontal Rule docs:
---) at a new line start to transform into a horizontal rule<hr> HTML element by defaultThe fastest way to add the horizontal rule plugin is with the BasicBlocksKit, which includes pre-configured HorizontalRulePlugin along with other basic block elements and their Plate UI components.
HrElement: Renders horizontal rule elements.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
Include HorizontalRulePlugin in your Plate plugins array when creating the editor.
import { HorizontalRulePlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
HorizontalRulePlugin,
],
});
You can configure the HorizontalRulePlugin with autoformat rules to automatically convert typed patterns like --- into horizontal rules.
import { KEYS } from 'platejs';
import { AutoformatPlugin } from '@platejs/autoformat';
import { HorizontalRulePlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
HorizontalRulePlugin,
AutoformatPlugin.configure({
options: {
rules: [
{
mode: 'block',
type: KEYS.hr,
match: ['---', 'ā-', '___ '],
format: (editor) => {
editor.tf.setNodes({ type: KEYS.hr });
editor.tf.insertNodes({
type: KEYS.p,
children: [{ text: '' }],
});
},
},
],
},
}),
],
});
AutoformatPlugin: Automatically converts typed patterns (like ---) into horizontal rules.You can add this item to the Insert Toolbar Button to insert horizontal rules:
{
icon: <MinusIcon />,
label: 'Divider',
value: KEYS.hr,
}
</Steps>
HorizontalRulePluginPlugin for inserting horizontal rules to separate content. Horizontal rules are void elements that render as <hr> tags by default.
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā