返回组件列表
操作

操作面板

适合承载重复工作流操作的紧凑命令面板。

页面预览
源码
这里展示 registry 中会被 shadcn 安装到目标项目的组件源码。
registry/default/action-panel/action-panel.tsx
import { DownloadIcon, PlusIcon, SettingsIcon } from "lucide-react"

import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"

type ActionPanelProps = {
  title?: string
  description?: string
  badge?: string
  actions?: [string, string, string]
  footer?: string
}

export function ActionPanel({
  title = "Quick actions",
  description = "Group common commands in a compact panel for dashboards and admin pages.",
  badge = "3 actions",
  actions = ["New component", "Export registry", "Configure library"],
  footer = "Keep actions close to the workflow they support.",
}: ActionPanelProps) {
  return (
    <Card className="w-full max-w-sm">
      <CardHeader>
        <div className="flex items-start justify-between gap-3">
          <div className="flex flex-col gap-1">
            <CardTitle>{title}</CardTitle>
            <CardDescription>{description}</CardDescription>
          </div>
          <Badge variant="outline">{badge}</Badge>
        </div>
      </CardHeader>
      <CardContent className="flex flex-col gap-2">
        <Button className="justify-start" variant="outline">
          <PlusIcon data-icon="inline-start" />
          {actions[0]}
        </Button>
        <Button className="justify-start" variant="outline">
          <DownloadIcon data-icon="inline-start" />
          {actions[1]}
        </Button>
        <Button className="justify-start" variant="outline">
          <SettingsIcon data-icon="inline-start" />
          {actions[2]}
        </Button>
      </CardContent>
      <CardFooter>
        <p className="text-sm text-muted-foreground">
          {footer}
        </p>
      </CardFooter>
    </Card>
  )
}