文档
骨架
骨架
用于在内容加载时显示占位符。
import { Skeleton } from "@repo/tailwindcss/ui/skeleton";
const SkeletonDemo = () => {
return (
<div class="flex items-center space-x-4">
<Skeleton class="h-12 w-12 rounded-full" />
<div class="space-y-2">
<Skeleton class="h-4 w-[250px]" />
<Skeleton class="h-4 w-[200px]" />
</div>
</div>
);
};
export default SkeletonDemo;
安装
npx shadcn-solid@latest add skeleton
将以下代码复制并粘贴到你的项目中
import { cn } from "@/libs/cn";
import { type ComponentProps, splitProps } from "solid-js";
export const Skeleton = (props: ComponentProps<"div">) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<div
class={cn("animate-pulse rounded-md bg-primary/10", local.class)}
{...rest}
/>
);
};
将以下代码复制并粘贴到你的项目中
import { cn } from "@/libs/cn";
import { type ComponentProps, splitProps } from "solid-js";
export const Skeleton = (props: ComponentProps<"div">) => {
const [local, rest] = splitProps(props, ["class"]);
return (
<div
class={cn("animate-pulse rounded-md bg-primary/10", local.class)}
{...rest}
/>
);
};
用法
import { Skeleton } from "@/components/ui/skeleton";
<Skeleton class="w-100px h-20px rounded-full" />