29 lines
770 B
TypeScript
29 lines
770 B
TypeScript
import { cva, type VariantProps } from "class-variance-authority";
|
|
|
|
import { cn } from "~/lib/utils";
|
|
|
|
// A skeleton's width and height are its content, so consumers size it through
|
|
// className (the lint contract allows layout there). Its shape is not.
|
|
const skeletonVariants = cva("bg-muted-foreground/15 motion-safe:animate-skeleton", {
|
|
variants: {
|
|
shape: {
|
|
block: "rounded-sm",
|
|
card: "rounded-lg",
|
|
pill: "rounded-full",
|
|
},
|
|
},
|
|
defaultVariants: { shape: "block" },
|
|
});
|
|
|
|
function Skeleton({
|
|
className,
|
|
shape,
|
|
...props
|
|
}: React.ComponentProps<"div"> & VariantProps<typeof skeletonVariants>) {
|
|
return (
|
|
<div className={cn(skeletonVariants({ shape }), className)} data-slot="skeleton" {...props} />
|
|
);
|
|
}
|
|
|
|
export { Skeleton };
|