Toolbar Layout Customization
Toolbar Layout Customization
Section titled “Toolbar Layout Customization”The @lyfie/luthor package provides a flexible toolbar layout system that allows you to customize the grouping and ordering of toolbar buttons to match your preferred editing interface.
Default Layouts
Section titled “Default Layouts”Luthor ships with two predefined toolbar layouts:
Traditional Layout (Default)
Section titled “Traditional Layout (Default)”The TRADITIONAL_TOOLBAR_LAYOUT groups toolbar items in a familiar pattern similar to word processors like Microsoft Word or Google Docs:
- Typography Controls - Font family, font size, line height
- Text Formatting - Bold, italic, underline, strikethrough, text color, text highlight
- Enhanced Formatting - Subscript, superscript, inline code, link
- Paragraph & Alignment - Block format (headings/paragraph), quote, text alignment (left, center, right, justify)
- Lists - Bullet list, numbered list, checklist, indent, outdent
- Insert Elements - Table, image, emoji, embeds, horizontal rule
- Code Blocks - Code block toggle
- History - Undo, redo
- Utilities - Command palette, theme toggle
Legacy Layout
Section titled “Legacy Layout”The DEFAULT_TOOLBAR_LAYOUT maintains the original grouping pattern for backward compatibility.
Using a Layout
Section titled “Using a Layout”With ExtensiveEditor
Section titled “With ExtensiveEditor”Pass the toolbarLayout prop to customize the toolbar:
import { ExtensiveEditor, TRADITIONAL_TOOLBAR_LAYOUT } from "@lyfie/luthor";
function MyEditor() { return ( <ExtensiveEditor placeholder="Start writing..." toolbarLayout={TRADITIONAL_TOOLBAR_LAYOUT} /> );}The ExtensiveEditor uses TRADITIONAL_TOOLBAR_LAYOUT by default, so you only need to specify it if you want to override with a custom layout.
With Core Toolbar Component
Section titled “With Core Toolbar Component”If you’re building a custom preset, you can pass the layout directly to the Toolbar component:
import { Toolbar, TRADITIONAL_TOOLBAR_LAYOUT } from "@lyfie/luthor/core";
function MyCustomEditor() { return ( <Toolbar commands={commands} hasExtension={hasExtension} activeStates={activeStates} isDark={isDark} toggleTheme={toggleTheme} onCommandPaletteOpen={handleCommandPaletteOpen} layout={TRADITIONAL_TOOLBAR_LAYOUT} /> );}Creating a Custom Layout
Section titled “Creating a Custom Layout”You can create your own toolbar layout by defining a ToolbarLayout object:
import type { ToolbarLayout } from "@lyfie/luthor";
const myCustomLayout: ToolbarLayout = { sections: [ { // Group basic formatting together items: ["bold", "italic", "underline", "strikethrough"], }, { // Typography controls items: ["fontFamily", "fontSize", "textColor"], }, { // Block-level formatting items: ["blockFormat", "alignLeft", "alignCenter", "alignRight"], }, { // Lists items: ["unorderedList", "orderedList", "indentList", "outdentList"], }, { // Insert tools items: ["link", "image", "table", "horizontalRule"], }, { // Utilities items: ["undo", "redo", "commandPalette", "themeToggle"], }, ],};Then use it in your editor:
<ExtensiveEditor toolbarLayout={myCustomLayout} />Available Toolbar Items
Section titled “Available Toolbar Items”Here’s the complete list of toolbar items you can include in your custom layout:
Typography
Section titled “Typography”fontFamily- Font family selectorfontSize- Font size selectorlineHeight- Line height selectortextColor- Text color pickertextHighlight- Text background highlight color picker
Basic Formatting
Section titled “Basic Formatting”bold- Bold textitalic- Italic textunderline- Underline textstrikethrough- Strikethrough text
Enhanced Formatting
Section titled “Enhanced Formatting”subscript- Subscript textsuperscript- Superscript textcode- Inline codelink- Insert/remove link
Block Format
Section titled “Block Format”blockFormat- Block type selector (paragraph, headings)quote- Blockquote togglealignLeft- Align text leftalignCenter- Align text centeralignRight- Align text rightalignJustify- Justify textcodeBlock- Code block toggle
unorderedList- Bullet listorderedList- Numbered listcheckList- ChecklistindentList- Indent list itemoutdentList- Outdent list item
Insert Elements
Section titled “Insert Elements”horizontalRule- Insert horizontal ruletable- Insert tableimage- Insert image (with URL/file upload options)emoji- Insert emojiembed- Insert embed (iframe/YouTube)
History
Section titled “History”undo- Undo last actionredo- Redo last undone action
Utilities
Section titled “Utilities”commandPalette- Open command palettethemeToggle- Toggle light/dark theme
- Items are automatically hidden if their corresponding extension is not loaded
- Empty sections (sections with no visible items) are not rendered
- The toolbar respects extension availability, so missing extensions won’t show buttons
- Each section is visually separated with appropriate spacing
Example: Minimal Layout
Section titled “Example: Minimal Layout”Here’s a minimal layout for a simple editor:
const minimalLayout: ToolbarLayout = { sections: [ { items: ["bold", "italic", "link"], }, { items: ["unorderedList", "orderedList"], }, { items: ["undo", "redo"], }, ],};Example: Writer-Focused Layout
Section titled “Example: Writer-Focused Layout”A layout optimized for long-form writing:
const writerLayout: ToolbarLayout = { sections: [ { items: ["fontSize", "fontFamily"], }, { items: ["bold", "italic", "underline"], }, { items: ["blockFormat", "quote"], }, { items: ["alignLeft", "alignCenter", "alignJustify"], }, { items: ["link", "image", "horizontalRule"], }, { items: ["undo", "redo", "commandPalette"], }, ],};