Icon
MediaSVG icon wrapper with size variants.
Preview
Usage
example.jsx
import { Icon } from "@/components/ui/icon";
export default function Example() {
return <Icon />;
}Source Code
Copy this file into components/ui/icon.jsx in your project.
icon.jsx
import { forwardRef } from "react";
import { cn } from "@/lib/utils";
const iconSizes = { xs: "h-3 w-3", sm: "h-4 w-4", md: "h-5 w-5", lg: "h-6 w-6", xl: "h-8 w-8" };
const Icon = forwardRef(({ className, size = "md", children, ...props }, ref) => (
<span ref={ref} className={cn("inline-flex shrink-0 items-center justify-center", iconSizes[size], className)} {...props}>
{children}
</span>
));
Icon.displayName = "Icon";
export { Icon };
Quick Install
Make sure you have the cn() utility set up. It requires clsx and tailwind-merge.
npm install clsx tailwind-merge