๐จ
UI Library
A collection of beautiful, reusable React components and CSS snippets built with Tailwind CSS and Framer Motion.
Toggles & Switches
Interactive switches for binary on/off states.
Basic Switch
Toggle.tsxLanguage: tsx
import { useState } from 'react';
import { motion } from 'framer-motion';
export function BasicToggle() {
const [isOn, setIsOn] = useState(false);
return (
<button
onClick={() => setIsOn(!isOn)}
className={`relative inline-flex h-7 w-12 items-center rounded-full transition-colors duration-300 ${
isOn ? 'bg-accent' : 'bg-surface border border-border'
}`}
>
<span className="sr-only">Toggle</span>
<motion.span
layout
className={`inline-block h-5 w-5 rounded-full bg-white shadow-md transform transition-transform ${
isOn ? 'translate-x-6' : 'translate-x-1'
}`}
/>
</button>
);
}Switch with Icons
Toggle.tsxLanguage: tsx
import { useState } from 'react';
import { motion } from 'framer-motion';
export function IconToggle() {
const [isOn, setIsOn] = useState(true);
return (
<button
onClick={() => setIsOn(!isOn)}
className={`relative inline-flex h-8 w-14 items-center rounded-full transition-colors duration-300 ${
isOn ? 'bg-green-500' : 'bg-surface border border-border'
}`}
>
<span className="sr-only">Enable notifications</span>
{/* Background Icons */}
<span className="absolute left-2 text-xs text-white opacity-100 transition-opacity">
โ
</span>
<span className="absolute right-2 text-xs text-muted opacity-100 transition-opacity">
โ
</span>
<motion.span
layout
className={`relative inline-flex h-6 w-6 items-center justify-center rounded-full bg-white shadow-md transform transition-transform ${
isOn ? 'translate-x-[calc(100%+8px)]' : 'translate-x-1'
}`}
>
<span className={`text-[10px] font-bold ${isOn ? 'text-green-500' : 'text-muted'}`}>
{isOn ? 'ON' : 'OFF'}
</span>
</motion.span>
</button>
);
}