Implementing Syncfusion React Toolbar
Component Overview
The Syncfusion React Toolbar component provides a flexible command bar for organizing and executing commands. It supports multiple item types (buttons, separators, inputs), responsive overflow modes, and comprehensive accessibility features.
Key Capabilities:
- Multiple item types: Button, Separator, Input
- Responsive overflow modes: Scrollable, Popup, MultiRow, Extended
- Built-in keyboard navigation and ARIA support
- Component rendering within toolbar items
- Customizable appearance and behavior
- Tab key navigation support
- Dynamic item management (add/remove/enable/disable)
- Rich event system (beforeCreate, clicked, keyDown, created, destroyed)
- Full RTL and locale support
- Stateless template rendering
Complete Table of Contents
1. Getting Started
File: references/getting-started.md
- Dependencies setup
- Project initialization (Vite/CRA)
- Package installation
- CSS theme imports (Tailwind, Bootstrap, Fluent, Material)
- Basic implementation examples
- Global configuration:
- Locale support for internationalization
- RTL (Right-to-Left) layout
- Persistence settings
- Collision detection
- HTML sanitizer
- Development server setup
2. Item Configuration
File: references/item-configuration.md
- ItemModel API Reference:
- Complete interface structure
- All 16 properties with types
- Property reference with descriptions
- Items array configuration patterns
- Configuration examples (simple, grouped, conditional, accessible)
- Button item type with properties:
- - Display text
- - Unique identifier
- / - Icons positioning
- - Custom width
- - Alignment (Left/Center/Right)
- - Disabled state
- - Visibility control
- - Custom CSS classes
- - HTML attributes
- - Priority display (Show/Hide/None)
- - Force popup display
- - Text display mode (Both/Overflow/Toolbar)
- Separator item type
- Input item type for components
- Tab navigation with
- Complete working examples
3. Responsive Modes
File: references/responsive-modes.md
- Scrollable Mode (default)
- Horizontal scrolling with navigation arrows
- Touch swipe support
- Keyboard arrow navigation
- Use cases: many items, large screens
- Popup Mode
- Dropdown overflow container
- Command priority control
- Compact appearance
- Use cases: limited space, mobile
- MultiRow Mode
- Item wrapping to multiple rows
- No scrolling needed
- All items visible
- Use cases: responsive width containers
- Extended Mode
- Multi-row with horizontal scrolling
- Row-level navigation
- Use cases: many items in limited width
- Command priority (Show/Hide/None)
- Text display options (Both/Overflow/Toolbar)
- Mode comparison table
- Practical examples for each mode
4. Accessibility & Keyboard Support
File: references/accessibility.md
- Compliance standards:
- WCAG 2.2 Level AA
- Section 508 compliance
- Screen reader support (NVDA, JAWS, VoiceOver)
- ARIA attributes:
- Keyboard navigation:
- allowKeyboard property control
- Arrow keys (Left/Right) navigation
- Home/End keys
- Tab/Shift+Tab for focus
- Enter/Space for activation
- Escape to close popups
- keyDown Event handling:
- Event parameters (currentItem, nextItem, originalEvent)
- Custom keyboard shortcuts
- Preventing default navigation
- Key-specific actions
- Screen reader support and testing
- Color contrast WCAG compliance
- Mobile/touch accessibility
- RTL support
- ARIA best practices
- Testing checklist and tools
5. Item Configuration (Continued)
File: references/item-configuration.md
- Button properties reference
- Separator styling
- Input components (NumericTextBox, DropDownList, CheckBox, RadioButton)
- Tab navigation control
- Complete toolbar examples
6. Styling & Customization
File: references/styling-customization.md
- CSS class structure:
- - Container
- - Item wrapper
- - Button
- - Icon element
- - Separator
- - Popup
- Toolbar container styling
- Item & button styling
- Icon styling and customization
- State styling (hover, focus, active, disabled)
- Theme integration (Tailwind, Bootstrap, Fluent, Material)
- Popup customization CSS classes:
- - Popup container
- - Dropdown toggle
- - Show priority items
- - Hide priority items
- - Popup text styling
- - Toolbar text styling
- Custom styling examples
- Performance optimization
- Complete styled examples
7. Advanced Features & Templates
File: references/advanced-features.md
- Template Configuration:
- Template basics (functions/JSX)
- Template properties
- When to use templates
- Item-Wise Custom Templates:
- Single item templates
- Multiple different templates
- State within templates
- Template styling
- Stateless Templates:
- Performance optimization
- CSS class customization
- Popup customization equivalents
- Toggle Buttons:
- Single toggle state
- Toggle groups (radio-like)
- CSS styling
- Link Items:
- Navigation links
- External links
- Breadcrumb patterns
- Tooltips:
- HTML title attribute
- Custom tooltip components
- Styling and positioning
- Rendering Other Components:
- Syncfusion components (DropDownList, NumericTextBox, ColorPicker)
- React components
- Custom components
- Command Customization:
- Click handlers
- Context menus
- Custom actions
- Dynamic Item Management:
- - Add items at runtime
- - Remove by index or ID
- - Enable/disable items
- - Show/hide items
- - Disable entire toolbar
- - Cleanup
- - Recalculate layout
- Event Handling:
- - Pre-initialization customization
- - Post-initialization callback
- - Item click events with ClickEventArgs
- - Keyboard events with KeyDownEventArgs
- - Cleanup event
- Scroll Step Customization:
- Control scroll distance
- Dynamic scroll step
- Touch swipe behavior
- Complete advanced example
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Package installation and dependencies
- Setup with Vite and React
- CSS imports and theme configuration
- Basic toolbar with ItemsDirective
- HTML element initialization
- Running the development server
Item Configuration & Types
📄 Read: references/item-configuration.md
- Button item type with properties (text, icons, width, align)
- Separator item type
- Input item type for components
- Tab key navigation with tabIndex
- Complete working examples
Responsive Modes
📄 Read: references/responsive-modes.md
- Scrollable mode (default behavior)
- Popup overflow mode
- Command priority (show, hide, none)
- Text display options
- Navigation and interaction patterns
Accessibility & Keyboard Support
📄 Read: references/accessibility.md
- WCAG 2.2 and Section 508 compliance
- ARIA attributes and roles
- Keyboard navigation keys
- Screen reader support
- Mobile device accessibility
Styling & Customization
📄 Read: references/styling-customization.md
- CSS customization patterns
- Toolbar and item styling
- Icon and button customization
- Hover and focus states
- Theme integration
Advanced Features & Templates
📄 Read: references/advanced-features.md
- Template configuration and patterns
- Item-wise custom templates
- Toggle buttons
- Link items
- Tooltips
- Rendering other Syncfusion components
- Command and scroll customization
Quick Start Example
jsx
import { ItemDirective, ItemsDirective, ToolbarComponent } from '@syncfusion/ej2-react-navigations';
import './App.css';
const App = () => {
return (
<ToolbarComponent id='toolbar'>
<ItemsDirective>
<ItemDirective text="Cut" prefixIcon="e-cut-icon" />
<ItemDirective text="Copy" prefixIcon="e-copy-icon" />
<ItemDirective text="Paste" prefixIcon="e-paste-icon" />
<ItemDirective type="Separator" />
<ItemDirective text="Bold" prefixIcon="e-bold-icon" />
<ItemDirective text="Italic" prefixIcon="e-italic-icon" />
<ItemDirective text="Underline" prefixIcon="e-underline-icon" />
</ItemsDirective>
</ToolbarComponent>
);
};
export default App;
Required CSS imports in App.css:
css
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-react-navigations/styles/tailwind3.css';
Common Patterns
Basic Toolbar with Buttons and Separators
Create a simple toolbar with button commands and visual separators between groups:
jsx
<ToolbarComponent>
<ItemsDirective>
{/* Edit commands */}
<ItemDirective text="Cut" />
<ItemDirective text="Copy" />
<ItemDirective type="Separator" />
{/* Format commands */}
<ItemDirective text="Bold" />
<ItemDirective text="Italic" />
</ItemsDirective>
</ToolbarComponent>
Toolbar with Icons
Use prefixIcon to add icons to buttons for better visual representation:
jsx
<ItemDirective text="Save" prefixIcon="e-save-icon" />
<ItemDirective text="Print" prefixIcon="e-print-icon" />
Responsive Overflow Handling
Choose between Scrollable (default) for continuous display or Popup for compact overflow:
jsx
{/* Scrollable mode with navigation arrows */}
<ToolbarComponent overflowMode="Scrollable">
{/* items */}
</ToolbarComponent>
{/* Popup mode with dropdown */}
<ToolbarComponent overflowMode="Popup">
{/* items */}
</ToolbarComponent>
Toolbar with Input Components
Include interactive components like dropdowns within toolbar items:
jsx
<ItemDirective type="Input" template={<DropDownComponent {...props} />} />
Key Props
| Property | Type | Description |
|---|
| string | Unique identifier for the toolbar |
| "Scrollable" | "Popup" | How to handle overflow items |
| string | Width of the toolbar container |
| ItemModel[] | Array of toolbar items |
| string | Display text for button items |
| string | Icon class for prefix position |
| string | Icon class for suffix position |
| "Button" | "Separator" | "Input" | Item type |
| "Left" | "Center" | "Right" | Item alignment |
| "Show" | "Hide" | "None" | Priority for popup mode |
| number | Tab navigation order |
| function | Custom template for items |
Common Use Cases
-
Text Editor Toolbar
- Format buttons (Bold, Italic, Underline)
- Alignment options
- Color and font pickers
- See: responsive-modes.md, advanced-features.md
-
File Operations Toolbar
- New, Open, Save, Save As buttons
- Print functionality
- Undo/Redo commands
- See: item-configuration.md, advanced-features.md
-
Responsive Mobile Toolbar
- Popup overflow mode for compact display
- Scrollable mode for continuous access
- See: responsive-modes.md
-
Accessible Command Bar
- Keyboard navigation support
- ARIA attributes
- Screen reader friendly
- See: accessibility.md
-
Customized Branded Toolbar
- Custom CSS styling
- Theme integration
- Company-specific icons
- See: styling-customization.md
Summary
The Toolbar component provides a comprehensive solution for command organization and execution in React applications. Start with getting-started.md for basic setup, then explore specific features based on your needs. Use advanced-features.md for template customization and complex scenarios.
Navigation Path:
- Getting Started → Basic toolbar setup
- Item Configuration → Add different item types
- Responsive Modes → Handle overflow
- Accessibility → Ensure keyboard support
- Styling → Customize appearance
- Advanced Features → Templates and custom components