Introduction
The@yoopta/ui package provides a collection of headless UI components that give you complete control over your editor’s interface. These components follow modern design patterns and best practices, offering flexibility and customization while maintaining excellent developer experience.
Starting with Yoopta Editor v4.10+, the core
@yoopta/editor is completely headless. All
UI components have been moved to the separate @yoopta/ui package, giving you full control over
appearance and behavior.Key Features
Fully Customizable
Every component supports custom styling through CSS variables, Tailwind classes, or inline
styles
Compound Components
Built with the compound component pattern for maximum flexibility and composition
TypeScript Support
Full TypeScript support with exported types for every component and hook
Accessibility
Built with accessibility in mind, following ARIA best practices
Installation
Available Components
Core UI Components
FloatingBlockActions
Floating buttons that appear when hovering over blocks
BlockOptions
Context menu for block actions (duplicate, delete, etc.)
Toolbar
Floating toolbar for text formatting on selection
ActionMenuList
Dropdown menu for block type selection
SlashActionMenuList
Slash command menu for quick block insertion
Theme System
Built-in theme system with light/dark mode support
Architecture
Component Types
Yoopta UI components fall into two categories:1. Self-Managed Components
These components automatically manage their own state and behavior:- FloatingBlockActions - Appears on block hover
- Toolbar - Appears on text selection
- SlashActionMenuList - Appears on
/command
2. Controlled Components
These components are controlled programmatically:- BlockOptions - Opened via
useBlockOptionsActions() - ActionMenuList - Opened via
useActionMenuListActions()
Two-Hook Pattern
Many components follow the two-hook pattern:- Full Hook - For the component that renders the UI (includes Floating UI, event listeners, etc.)
- Lightweight Hook - For other components that just need to interact with the UI
Quick Start
Here’s a complete example using the new UI components:Styling
CSS Variables
All components use CSS variables (shadcn/ui style) for theming:Custom Styles
Override styles using:- CSS Variables - Change theme globally
- CSS Classes - Target specific elements
- Inline Styles - Component-level customization
- Tailwind - Use utility classes directly
State Management
UI components use Zustand for state management, allowing:- ✅ Shared state across components
- ✅ Singleton stores (one instance per component type)
- ✅ Programmatic control from anywhere
- ✅ Lightweight and performant