示例工程 16-shadcn-ui-component-layer

16-shadcn-ui-component-layer/app/src/components/ui/field.tsx

tsx · 0.7 KB

// vendored from shadcn/ui (base style) — field
// source: https://ui.shadcn.com/docs/components/field
// fetched: 2026-11-26 · shadcn CLI 4.23.0 · base-nova
// 本地修改:最小实现,label 包裹控件,不引入 Field.Group
import type { ReactNode } from "react";
import { cn } from "@/lib/utils";

export function Field({
  label,
  description,
  className,
  children,
}: {
  label: string;
  description?: string;
  className?: string;
  children: ReactNode;
}) {
  return (
    <label className={cn("flex flex-col gap-1.5", className)}>
      <span className="text-xs font-medium text-text">{label}</span>
      {children}
      {description ? (
        <span className="text-xs text-muted">{description}</span>
      ) : null}
    </label>
  );
}