🌐 Nodejs.cn

旋转器

一个可以用来显示加载状态的指示器。

Processing payment...
$100.00
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"
components/ui/spinner.tsx
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.

SyncingUpdatingProcessing
import { Badge } from "@/components/ui/badge"
import { Spinner } from "@/components/ui/spinner"

输入组

🌐 Input Group

Validating...
import {
  InputGroup,
  InputGroupAddon,

🌐 Empty

Processing your request
Please wait while we process your request. Do not refresh the page.
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"