# @commercetools-uikit/field-errors

> Renders errors based on configuration.

Latest version **20.6.7** (published 2026-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @commercetools-uikit/field-errors
pnpm add @commercetools-uikit/field-errors
yarn add @commercetools-uikit/field-errors
bun add @commercetools-uikit/field-errors
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 20.6.7 |
| Published | 2026-07-17 |
| First published | 2019-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 27.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 154 |
| Maintainers | emmenko, commercetools-admin, tdeekens |
| Keywords | javascript, typescript, design-system, react, uikit |

## Links

- npm: https://www.npmjs.com/package/@commercetools-uikit/field-errors
- Repository: https://github.com/commercetools/ui-kit
- Homepage: https://uikit.commercetools.com
- Issues: https://github.com/commercetools/ui-kit/issues
- npm.io page: https://npm.io/package/@commercetools-uikit/field-errors

## Dependencies (5)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.20.13
- [@emotion/react](https://npm.io/package/@emotion/react.md) ^11.10.5
- [@emotion/styled](https://npm.io/package/@emotion/styled.md) ^11.10.5
- [@babel/runtime-corejs3](https://npm.io/package/@babel/runtime-corejs3.md) ^7.20.13
- [@commercetools-uikit/messages](https://npm.io/package/@commercetools-uikit/messages.md) ^20.6.7

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 20.6.7 (latest) — 2026-07-17
- 0.0.0-canary-20260831181816 (canary) — 2026-08-31
- 0.0.0-FEC-938-ui-kit-post-pnpm-tooling-polish-catalogs-bundlewatch-bundlesize-20260518121756 (FEC-938-ui-kit-post-pnpm-tooling-polish-catalogs-bundlewatch-bundlesize) — 2026-05-18
- 0.0.0-migration-pnpm-20260513114959 (migration-pnpm) — 2026-05-13
- 0.0.0-CRAFT-2040-rich-text-input-destroys-hyperlink-tag-20260219190637 (CRAFT-2040-rich-text-input-destroys-hyperlink-tag) — 2026-02-19
- 0.0.0-fec-155-react-19-20250528075244 (fec-155-react-19) — 2025-05-28
- 0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339 (FCT-1500-adjust-legacy-css-reset) — 2025-05-27
- 0.0.0-SUPPORT-32352-de-ch-money-input-20250509174254 (SUPPORT-32352-de-ch-money-input) — 2025-05-09
- 0.0.0-main-20250115172531 (main) — 2025-01-15
- 0.0.0-preview-fec-155-react-19-20250113184401 (preview-fec-155-react-19) — 2025-01-13
- 0.0.0-preview-test-icon-entrypoints-20241212201418 (preview-test-icon-entrypoints) — 2024-12-12
- 0.0.0-preview-test-icon-pure-annotations-20241211181046 (preview-test-icon-pure-annotations) — 2024-12-11
- 0.0.0-preview-test-icon-bundle-20241210182318 (preview-test-icon-bundle) — 2024-12-10
- 0.0.0-preview-test-canary-preview-20241204111237 (preview-test-canary-preview) — 2024-12-04
- 0.0.0-preview-FCT-1187-20241024123200 (preview) — 2024-10-24
- … 1054 more at https://npm.io/package/@commercetools-uikit/field-errors/versions

## README

<!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -->
<!-- This file is created by the `pnpm generate-readme` script. -->

# FieldErrors

## Description

Renders errors based on configuration.

## Installation

```
pnpm add @commercetools-uikit/field-errors
```

```
npm --save install @commercetools-uikit/field-errors
```

Additionally install the peer dependencies (if not present)

```
pnpm add react react-intl
```

```
npm --save install react react-intl
```

## Usage

```jsx
import FieldErrors from '@commercetools-uikit/field-errors';

const Example = () => (
  // This example shows how to handle custom errors on top of the
  // predefined errors of FieldErrors which this component and other
  // Field components use under the hood.
  <FieldErrors
    errors={{
      [FieldErrors.errors.MISSING]: true,
      duplicate: true,
      minLength: true,
    }}
    isVisible={true}
    renderError={(key) => {
      switch (key) {
        case 'duplicate':
          return 'This is already in use. It must be unique.';
        default:
          // When null is returned then the default error handling from
          // renderDefaultError will kick in for that error.
          return null;
      }
    }}
    renderDefaultError={(key) => {
      switch (key) {
        case 'minLength':
          return 'This is too short.';
        default:
          // When null is returned then the error handling defined in
          // FieldError itself will kick in
          return null;
      }
    }}
  />
);

export default Example;
```

## Properties

| Props                | Type                                                           | Required | Default | Description                                                                                                                                                                                                                                   |
| -------------------- | -------------------------------------------------------------- | :------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                 | `string`                                                       |          |         | ID of the error field.                                                                                                                                                                                                                        |
| `errors`             | `Record`                                                       |          |         | List of errors. Only entries with truthy values will count as active errors.                                                                                                                                                                  |
| `isVisible`          | `boolean`                                                      |          |         | `true` when the error messages should be rendered. Usually you'd pass in a `touched` state of fields.                                                                                                                                         |
| `renderError`        | `Function`<br/>[See signature.](#signature-rendererror)        |          |         | Function which gets called with each error key (from the `errors` prop) and may render an error message or return `null` to hand the error handling off to `renderDefaultError`.                                                              |
| `renderDefaultError` | `Function`<br/>[See signature.](#signature-renderdefaulterror) |          |         | Function which gets called with each error key (from the `errors` prop) for which `renderError` returned `null`.&#xA;It may render an error message or return `null` to hand the error handling off to `FieldError`s built-in error handling. |

## Signatures

### Signature `renderError`

```ts
(key: string, error?: boolean) => ReactNode;
```

### Signature `renderDefaultError`

```ts
(key: string, error?: boolean) => ReactNode;
```

## Static properties

### `FieldErrors.errorTypes`

An enum of known errors which `FieldErrors` can handle itself. You might want to use this while constructing the error object you're passing as the `errors` prop.

---
_Source: https://npm.io/package/@commercetools-uikit/field-errors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
