e78df62cd1
- 重构 Button、Card、Badge、Input、Textarea 等基础组件 - 新增 Accordion、Alert、Dialog、Dropdown、Form 等 shadcn/ui 组件 - 新增 AnimatedCounter、StatsShowcase、MetricCard 等数据展示组件 - 新增 ScrollReveal 滚动动画组件 - 重构 Toast 通知系统与 Tooltip 提示组件 - 更新设计令牌系统,对齐新品牌视觉
35 lines
954 B
TypeScript
35 lines
954 B
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
import { Slot } from '@radix-ui/react-slot';
|
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
/**
|
|
* 标准 shadcn/ui Label 组件
|
|
* 基于 @radix-ui/react-label
|
|
*/
|
|
const labelVariants = cva(
|
|
'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50'
|
|
);
|
|
|
|
function Label({
|
|
className,
|
|
asChild,
|
|
...props
|
|
}: React.ComponentProps<typeof LabelPrimitive.Root> &
|
|
VariantProps<typeof labelVariants> & { asChild?: boolean }) {
|
|
const Comp = asChild ? Slot : LabelPrimitive.Root;
|
|
|
|
return (
|
|
<Comp
|
|
data-slot="label"
|
|
className={cn(labelVariants(), className)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export { Label, labelVariants };
|