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, offering flexibility and customization while maintaining excellent developer experience.
Starting with Yoopta Editor v6, the core
@yoopta/editor is completely headless. All UI
components use the compound component pattern with no shared global state.Key Features
API
Compound components with controlled/uncontrolled patterns
TypeScript Support
Full TypeScript support with exported types for every component
Accessibility
Built with accessibility in mind, following ARIA best practices
Installation
Import Styles
Two ways to import the@yoopta/ui package:
1. Full Package Import
Import everything from the main entry point:2. Subpath Imports (Recommended for Bundle Size)
Import only what you need using subpath exports for better tree-shaking and smaller bundles:Available Subpaths
Available Components
All components from@yoopta/ui are listed below. Dedicated doc pages exist for: FloatingBlockActions, BlockOptions, FloatingToolbar, ActionMenuList, SlashCommandMenu, SelectionBox, and Block DnD. HighlightColorPicker and ElementOptions are exported and usable but do not have dedicated pages yet.
Core UI Components
FloatingBlockActions
Floating buttons that appear when hovering over blocks
BlockOptions
Context menu for block actions (duplicate, delete, turn into)
FloatingToolbar
Floating toolbar for text formatting on selection
ActionMenuList
Block type menu for “Turn into” actions
SlashCommandMenu
Slash command menu for quick block insertion
SelectionBox
Rectangle selection for selecting multiple blocks
Block DnD
Drag and drop support for reordering blocks
HighlightColorPicker
Color picker for highlight and text color (subpath:
@yoopta/ui/highlight-color-picker)ElementOptions
Options panel for element props (links, images, etc.) (subpath:
@yoopta/ui/element-options)Portal and Overlay are also exported for rendering outside the editor tree (subpaths: @yoopta/ui/portal, @yoopta/ui/overlay).
Architecture
Compound Components
All components follow the compound component pattern:Controlled vs Self-Managed
Components fall into two categories:1. Self-Managed Components
These handle their own visibility automatically:- FloatingBlockActions - Appears on block hover
- FloatingToolbar - Appears on text selection
- SlashCommandMenu - Appears on
/command
2. Controlled Components
These require explicit open/close control:- BlockOptions - Controlled via
open/onOpenChange - ActionMenuList - Controlled via
open/onOpenChange
The frozen Prop Pattern
When opening submenus, use the frozen prop to pause the parent’s tracking:
Quick Start
Here’s a complete example using the UI components:Plugins and marks are passed to
createYooptaEditor, not to YooptaEditor. UI components must be
children of YooptaEditor so they can use useYooptaEditor() for the editor instance.Styling
How styles work
- Each UI component ships with its own CSS. Component styles use a shared set of design tokens (CSS variables) defined in the package (
packages/core/ui/src/styles/variables.css). - Each component’s CSS file imports this variables file via
@import '../styles/variables.css'. At build time,postcss-importinlines the variables into the component CSS, so default styling works without any extra imports in your app. - You do not need to import
variables.cssyourself for the components to look correct. Import a component from@yoopta/ui(or a subpath), and its styles (including the inlined variables) are applied.
Theming with CSS variables
All components use the same token names (shadcn/ui-style HSL values). Override them in your app to theme:hsl() wrapper; components use them as hsl(var(--yoopta-ui-background)).
Custom styles
You can still override appearance with:- CSS variables — Override the tokens above in
:rootor.darkfor global theme. - ClassName — Pass
classNameto component parts to target specific elements. - Inline styles — For one-off overrides.
- Tailwind — Use utility classes on the same elements.
TypeScript Support
Full TypeScript support with exported types:Migration from v4.9
If you’re migrating from the old built-in UI: Before (v4.9):Next Steps
FloatingBlockActions
Learn about the floating block actions component
BlockOptions
Add block context menus
FloatingToolbar
Build a custom formatting toolbar
ActionMenuList
Block type menu for “Turn into”
SlashCommandMenu
Slash command for block insertion
SelectionBox
Rectangle selection for multiple blocks
Block DnD
Add drag and drop for blocks

