Text
Highlight Text
Animated text highlight component with gradient backgrounds and in-view detection. Perfect for React applications requiring text emphasis with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/highlight-text.json
npx shadcn@latest add https://www.shadcn.io/registry/highlight-text.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/highlight-text.json
bunx shadcn@latest add https://www.shadcn.io/registry/highlight-text.json
Features
- Gradient animations with smooth background size transitions from 0% to 100% width
- In-view detection triggers highlight animation when component enters viewport using Motion
- Customizable transitions with configurable duration, easing, and animation timing
- Theme-aware styling with automatic light/dark mode gradient colors and proper contrast
- TypeScript support with complete interface definitions for all animation props
- Performance optimized using CSS transforms for smooth 60fps highlight animations
Use Cases
This free open source React component works well for:
- Landing pages - Highlight key phrases and call-to-action text in Next.js applications
- Content marketing - Emphasize important points in articles using TypeScript and Tailwind CSS
- Educational content - Draw attention to key concepts and definitions
- Product demos - Highlight features and benefits with engaging visual effects
API Reference
HighlightText
Prop | Type | Default | Description |
---|---|---|---|
text | string | required | Text content to be highlighted |
inView | boolean | false | Only animate when component enters viewport |
inViewMargin | string | "0px" | Margin for in-view detection trigger |
inViewOnce | boolean | true | Only trigger in-view animation once |
transition | Transition | { duration: 2, ease: 'easeInOut' } | Motion transition configuration for highlight animation |
className | string | - | CSS classes for custom styling and text appearance |
Default Styling
- Light mode - Blue to purple gradient (from-blue-100 to-purple-100)
- Dark mode - Saturated blue to purple gradient (from-blue-500 to-purple-500)
- Padding - 8px horizontal, 4px vertical for readable spacing
- Border radius - 8px for modern, rounded appearance
Implementation Notes
- Uses CSS backgroundSize animation for smooth highlight effect
- Background position is set to "left center" for consistent animation start
- Display is set to "inline" to maintain text flow within paragraphs
- Component forwards ref for advanced use cases and external control
- Supports all standard span HTML attributes and event handlers
- Animation automatically cleans up on component unmount
Gradient Text
Animated gradient text with flowing color effects and optional neon glow. Perfect for React applications requiring eye-catching typography with Next.js integration and TypeScript support.
Rolling Text
3D rolling text animation with character-by-character reveal effects. Perfect for React applications requiring engaging text transitions with Next.js integration and TypeScript support.