Loading...
Features
- Apply bold formatting to emphasize important text
- Keyboard shortcut support for quick formatting (
Cmd + B
) - Renders as
<strong>
HTML element by default
Kit Usage
Installation
The fastest way to add the bold plugin is with the BasicMarksKit
, which includes pre-configured BoldPlugin
along with other basic marks and their Plate UI components.
Add Kit
Add the kit to your plugins:
import { createPlateEditor } from 'platejs/react';
import { BasicMarksKit } from '@/components/editor/plugins/basic-marks-kit';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...BasicMarksKit,
],
});
Manual Usage
Installation
pnpm add @platejs/basic-nodes
Add Plugin
Include BoldPlugin
in your Plate plugins array when creating the editor.
import { BoldPlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
BoldPlugin,
],
});
Configure Plugin
You can configure the BoldPlugin
with custom keyboard shortcuts.
import { BoldPlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
BoldPlugin.configure({
shortcuts: { toggle: 'mod+b' },
}),
],
});
shortcuts.toggle
: Defines a keyboard shortcut to toggle bold formatting.
Add Toolbar Button
You can add MarkToolbarButton
to your Toolbar to toggle bold formatting.
Plugins
BoldPlugin
Plugin for bold text formatting. Renders as <strong>
HTML element by default.
Transforms
tf.bold.toggle
Toggles the bold formatting for the selected text.
Default Shortcut: Cmd + B