Preview
Installation
- CLI
- Manual
Usage
Basic Usage
In a Sidebar Navigation
Custom Dimensions
Different Positions
Props
Name of the component to preview. Must match a folder name in
components/previews/ containing a default.tsx export.The element that triggers the tooltip on hover. Usually a link or button.
Position of the tooltip relative to the trigger element
Width of the tooltip container in pixels
Height of the tooltip container in pixels
Scale factor for the preview (0.8 = 80% of original size). Useful for fitting larger components in the preview.
Additional CSS classes to apply to the trigger wrapper
Features
Dynamic Component Loading
The tooltip uses React’s dynamic imports to lazy-load preview components only when needed. This keeps your initial bundle size small and loads previews on-demand.Positioning System
Built on Radix UI’s tooltip positioning, which automatically:- Positions the tooltip relative to the trigger
- Handles viewport boundaries
- Flips to the opposite side if there’s not enough space
- Centers the tooltip along the trigger element
Loading States
Shows a spinning loader while the component preview is being loaded, providing visual feedback during the import process.Graceful Fallbacks
If a preview component can’t be found or fails to load:- Displays “Preview not found” message
- Logs error to console for debugging
- Doesn’t break the parent component
Scale Control
Thescale prop transforms the preview content, allowing you to:
- Fit large components in smaller tooltips
- Maintain aspect ratios
- Control preview density
Smooth Animations
Includes fade and zoom animations:- Fade in/out on open/close
- Zoom effect for modern feel
- Slide animation based on position
- Respects
prefers-reduced-motion
Dark Mode Support
Fully themed for dark mode with:- Adaptive background colors
- Themed borders and shadows
- Arrow that matches tooltip background
Preview Component Structure
For the tooltip to work, your preview components should follow this structure:Usage in Gaia
The Component Preview Tooltip speeds up development by letting developers preview components instantly in the Gaia UI registry without navigation. Perfect for:- Component library documentation
- Design system browsers
- Navigation menus with component links
- Component selection interfaces
Accessibility
- Built on Radix UI’s accessible tooltip primitives
- Keyboard navigation support
- Screen reader compatible
- Respects
prefers-reduced-motion - Trigger wrapped in focusable element
The tooltip has a
delayDuration of 0ms for instant feedback. Adjust this in the Tooltip component if you prefer a delay before showing the preview.