- 手风琴
- 警报
- 警报对话框
- 纵横比
- 头像
- 徽章
- 面包屑
- 按钮
- 按钮组
- 日历
- 卡片
- 轮播
- 图表
- 复选框
- 可折叠
- 组合框
- 命令
- 上下文菜单
- 数据表格
- 日期选择器
- 对话框
- 方向
- 抽屉
- 下拉菜单
- 空
- 字段
- 悬停卡
- 输入
- 输入组
- 输入 OTP
- 条目
- 键盘
- 标签
- 菜单栏
- 原生选择
- 导航菜单
- 分页
- 弹出窗口
- 进度
- 单选按钮组
- 可调整大小
- 滚动区域
- 选择
- 分隔符
- 工作表
- 侧边栏
- 骨架
- 滑块
- Sonner
- 旋转器
- 切换
- 表格
- 标签
- 文本区域
- Toast
- 切换
- 切换组
- 工具提示
- 排版
- 手风琴
- 警报
- 警报对话框
- 纵横比
- 头像
- 徽章
- 面包屑
- 按钮
- 按钮组
- 日历
- 卡片
- 轮播
- 图表
- 复选框
- 可折叠
- 组合框
- 命令
- 上下文菜单
- 数据表格
- 日期选择器
- 对话框
- 方向
- 抽屉
- 下拉菜单
- 空
- 字段
- 悬停卡
- 输入
- 输入组
- 输入 OTP
- 条目
- 键盘
- 标签
- 菜单栏
- 原生选择
- 导航菜单
- 分页
- 弹出窗口
- 进度
- 单选按钮组
- 可调整大小
- 滚动区域
- 选择
- 分隔符
- 工作表
- 侧边栏
- 骨架
- 滑块
- Sonner
- 旋转器
- 切换
- 表格
- 标签
- 文本区域
- Toast
- 切换
- 切换组
- 工具提示
- 排版
import {
Item,
ItemContent,安装
🌐 Installation
pnpm dlx shadcn@latest add spinner
用法
🌐 Usage
import { Spinner } from "@/components/ui/spinner"<Spinner />自定义
🌐 Customization
你可以通过编辑 Spinner 组件,将默认的加载图标替换为任何其他图标。
🌐 You can replace the default spinner icon with any other icon by editing the Spinner component.
import { LoaderIcon } from "lucide-react"
import { cn } from "@/lib/utils"import { LoaderIcon } from "lucide-react"
import { cn } from "@/lib/utils"
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
return (
<LoaderIcon
role="status"
aria-label="Loading"
className={cn("size-4 animate-spin", className)}
{...props}
/>
)
}
export { Spinner }示例
🌐 Examples
大小
🌐 Size
使用 size-* 工具类来更改加载图标的大小。
🌐 Use the size-* utility class to change the size of the spinner.
import { Spinner } from "@/components/ui/spinner"
export function SpinnerSize() {按钮
🌐 Button
在按钮上添加一个加载旋转器以指示加载状态。记得使用 data-icon="inline-start" 属性将旋转器添加到按钮的开始位置,使用 data-icon="inline-end" 属性将旋转器添加到按钮的结束位置。
🌐 Add a spinner to a button to indicate a loading state. Remember to use the data-icon="inline-start" prop to add the spinner to the start of the button and the data-icon="inline-end" prop to add the spinner to the end of the button.
import { Button } from "@/components/ui/button"
import { Spinner } from "@/components/ui/spinner"
徽章
🌐 Badge
在徽章上添加一个加载指示器以表示加载状态。记得使用 data-icon="inline-start" 属性将加载指示器添加到徽章的开始位置,使用 data-icon="inline-end" 属性将加载指示器添加到徽章的结束位置。
🌐 Add a spinner to a badge to indicate a loading state. Remember to use the data-icon="inline-start" prop to add the spinner to the start of the badge and the data-icon="inline-end" prop to add the spinner to the end of the badge.
import { Badge } from "@/components/ui/badge"
import { Spinner } from "@/components/ui/spinner"
输入组
🌐 Input Group
import {
InputGroup,
InputGroupAddon,空
🌐 Empty
import { Button } from "@/components/ui/button"
import {
Empty,从右到左
🌐 RTL
要在 shadcn/ui 中启用 RTL 支持,请参阅 RTL 配置指南。
🌐 To enable RTL support in shadcn/ui, see the RTL configuration guide.
"use client"
import * as React from "react"