Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

602 B
Raw Blame
"use client"
import { Input } from '@/components/atoms/Input/Input';
import { cn } from "@/lib/utils"
import { FieldError } from "react-hook-form"

type LabeledInputProps = {
  label: string
  error?: FieldError
} & React.InputHTMLAttributes<HTMLInputElement>

export const LabeledInput = ({
  error,
  label,
  className,
  ...props
}: LabeledInputProps) => (
  <label className={cn("label-sm block", className)}>
    <p className={cn(error && "text-negative")}>{label}</p>
    <Input error={!!error} {...props} />
    {error && <p className="label-sm text-negative">{error.message}</p>}
  </label>
)