A beautiful animated border component with theme-aware styling and customizable effects
Automatically adapts to light and dark themes
Control color, speed, and animation properties
Render as any HTML element using the 'as' prop
Full TypeScript support with proper type inference
<StarBorder>
Theme-aware Border
</StarBorder>
<StarBorder
color="#3b82f6"
speed="4s"
as="div"
>
Custom Border
</StarBorder>
Seamlessly integrates with your existing React workflow
Built for modern development environments and workflows
Copy the component code and start creating beautiful animated borders in your React applications today.
Discover practical ways to implement StarBorder in your applications
Create eye-catching call-to-action buttons that grab user attention
<StarBorder
as="button"
color="#3b82f6"
speed="4s"
>
Get Started
</StarBorder>
Highlight important features with animated borders
Enhanced functionality with animated borders
<StarBorder
as="div"
color="#10b981"
className="w-full"
>
<div className="p-4">
Feature Content
</div>
</StarBorder>
Create distinctive navigation elements that stand out
<StarBorder
as="a"
href="/page"
color="#8b5cf6"
speed="5s"
>
Active Page
</StarBorder>
Highlight premium user badges and status indicators
Create engaging loading indicators with animated borders
Draw attention to important alerts and messages
Enhance form inputs and submission buttons
Tailor StarBorder to match your design system with flexible customization options
Customize border colors to match your brand
color="#ef4444"
color="#10b981"
color="#8b5cf6"
color="#f59e0b"
Control animation timing for perfect feel
Render as any HTML element using polymorphic 'as' prop
HTML element to render (default: "button")
Border animation color (default: theme foreground)
Animation duration (default: "6s")
Additional CSS classes
Content to display inside border
<StarBorder
as="button"
color="#ef4444"
speed="3s"
className="hover:scale-105"
onClick={handleClick}
>
Delete Item
</StarBorder>
<StarBorder
as="a"
href="/dashboard"
color="#8b5cf6"
speed="8s"
className="no-underline"
>
Dashboard
</StarBorder>
<StarBorder
as="div"
color="#10b981"
speed="12s"
className="w-full max-w-md"
>
<div className="p-6">
<h3>Feature Card</h3>
<p>Card content here</p>
</div>
</StarBorder>
Adapts to light/dark themes automatically
Uses CSS variables for seamless integration
Works with shadcn/ui and other systems
Complete implementation guide with step-by-step setup and real-world examples
npx shadcn-ui@latest init
Set up shadcn/ui project with Tailwind CSS and TypeScript support
mkdir -p components/ui
touch components/ui/star-border.tsx
Create the component directory and file structure
// tailwind.config.js
extend: { animations... }
Add custom animations to your Tailwind configuration
components/ui/star-border.tsx
import { cn } from "@/lib/utils"
import { ElementType, ComponentPropsWithoutRef } from "react"
interface StarBorderProps<T extends ElementType> {
as?: T
color?: string
speed?: string
className?: string
children: React.ReactNode
}
export function StarBorder<T extends ElementType = "button">({
as, className, color, speed = "6s", children, ...props
}: StarBorderProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof StarBorderProps<T>>) {
const Component = as || "button"
const defaultColor = color || "hsl(var(--foreground))"
return (
<Component
className={cn(
"relative inline-block py-[1px] overflow-hidden rounded-[20px]",
className
)}
{...props}
>
// Animation elements...
</Component>
)
}
tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
theme: {
extend: {
animation: {
'star-movement-bottom': 'star-movement-bottom linear infinite alternate',
'star-movement-top': 'star-movement-top linear infinite alternate',
},
keyframes: {
'star-movement-bottom': {
'0%': { transform: 'translate(0%, 0%)', opacity: '1' },
'100%': { transform: 'translate(-100%, 0%)', opacity: '0' },
},
'star-movement-top': {
'0%': { transform: 'translate(0%, 0%)', opacity: '1' },
'100%': { transform: 'translate(100%, 0%)', opacity: '0' },
},
},
},
},
}
components/demo.tsx
import { StarBorder } from "@/components/ui/star-border"
export function StarBorderDemo() {
return (
<div className="space-y-8">
<StarBorder>
Theme-aware Border
</StarBorder>
<StarBorder
color="#3b82f6"
speed="4s"
>
Custom Blue Border
</StarBorder>
</div>
)
}
<StarBorder
as="button"
color="#10b981"
speed="5s"
className="hover:scale-105 transition-transform"
onClick={() => handleSignup()}
>
Start Free Trial
</StarBorder>
<StarBorder
as="a"
href="/dashboard"
color="#8b5cf6"
speed="8s"
className="no-underline"
>
Dashboard
</StarBorder>
<StarBorder
as="div"
color="#f59e0b"
speed="10s"
className="w-full max-w-sm"
>
<div className="p-6 text-center">
<h3 className="text-xl font-bold mb-2">
Premium Feature
</h3>
<p className="text-gray-600">
Enhanced functionality
</p>
</div>
</StarBorder>
Copy the StarBorder component to components/ui/
Ensure the directory structure matches shadcn/ui conventions
Update your tailwind.config.js
Add the custom animations to the extend section
Import and use in your components
Start creating beautiful animated borders
All code examples are ready to copy and paste into your project. No additional dependencies required.