Home / Function/ FieldError() — ui Function Reference

FieldError() — ui Function Reference

Architecture documentation for the FieldError() function in field.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  5310f2cb_cb64_6f14_8686_0ccb7531eb1b["FieldError()"]
  ffc014c9_65b6_798a_d0f3_5c78f720c14b["field.tsx"]
  5310f2cb_cb64_6f14_8686_0ccb7531eb1b -->|defined in| ffc014c9_65b6_798a_d0f3_5c78f720c14b
  style 5310f2cb_cb64_6f14_8686_0ccb7531eb1b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/registry/default/ui/field.tsx lines 186–231

function FieldError({
  className,
  children,
  errors,
  ...props
}: React.ComponentProps<"div"> & {
  errors?: Array<{ message?: string } | undefined>
}) {
  const content = useMemo(() => {
    if (children) {
      return children
    }

    if (!errors) {
      return null
    }

    if (errors?.length === 1 && errors[0]?.message) {
      return errors[0].message
    }

    return (
      <ul className="ml-4 flex list-disc flex-col gap-1">
        {errors.map(
          (error, index) =>
            error?.message && <li key={index}>{error.message}</li>
        )}
      </ul>
    )
  }, [children, errors])

  if (!content) {
    return null
  }

  return (
    <div
      role="alert"
      data-slot="field-error"
      className={cn("text-destructive text-sm font-normal", className)}
      {...props}
    >
      {content}
    </div>
  )
}

Subdomains

Frequently Asked Questions

What does FieldError() do?
FieldError() is a function in the ui codebase, defined in deprecated/www/registry/default/ui/field.tsx.
Where is FieldError() defined?
FieldError() is defined in deprecated/www/registry/default/ui/field.tsx at line 186.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free