# @commercetools-uikit/time-field

> A controlled date input component for single date.

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

## Install

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

## 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 | 13 |
| Unpacked size | 48 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/time-field
- 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/time-field

## Dependencies (13)

- [react-intl](https://npm.io/package/react-intl.md) ^7.1.4
- [@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/utils](https://npm.io/package/@commercetools-uikit/utils.md) ^20.6.7
- [@commercetools-uikit/time-input](https://npm.io/package/@commercetools-uikit/time-input.md) ^20.6.7
- [@commercetools-uikit/constraints](https://npm.io/package/@commercetools-uikit/constraints.md) ^20.6.7
- [@commercetools-uikit/field-label](https://npm.io/package/@commercetools-uikit/field-label.md) ^20.6.7
- [@commercetools-uikit/field-errors](https://npm.io/package/@commercetools-uikit/field-errors.md) ^20.6.7
- [@commercetools-uikit/design-system](https://npm.io/package/@commercetools-uikit/design-system.md) ^20.6.7
- [@commercetools-uikit/field-warnings](https://npm.io/package/@commercetools-uikit/field-warnings.md) ^20.6.7
- [@commercetools-uikit/spacings-stack](https://npm.io/package/@commercetools-uikit/spacings-stack.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
- … 1169 more at https://npm.io/package/@commercetools-uikit/time-field/versions

## README

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

# TimeField

## Description

A controlled date input component for single date.

## Installation

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

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

Additionally install the peer dependencies (if not present)

```
pnpm add react
```

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

## Usage

```jsx
import TimeField from '@commercetools-uikit/time-field';

const Example = () => (
  <TimeField
    title="Release Date"
    value="15:30"
    onChange={(event) => alert(event.target.value)}
  />
);

export default Example;
```

## Properties

| Props                  | Type                                                                                                  | Required | Default   | Description                                                                                                                                                                                                                                                           |
| ---------------------- | ----------------------------------------------------------------------------------------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                   | `string`                                                                                              |          |           | Used as HTML id property. An id is auto-generated when it is not specified.                                                                                                                                                                                           |
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` |          | `'scale'` | Horizontal size limit of the input fields.                                                                                                                                                                                                                            |
| `errors`               | `Record`                                                                                              |          |           | A map of errors. Error messages for known errors are rendered automatically.&#xA;<br/>&#xA;Unknown errors will be forwarded to renderError.                                                                                                                           |
| `warnings`             | `Record`                                                                                              |          |           | A map of warnings. Warning messages for known warnings are rendered automatically.&#xA;<br/>&#xA;Unknown warnings will be forwarded to renderWarning.                                                                                                                 |
| `renderError`          | `Function`<br/>[See signature.](#signature-rendererror)                                               |          |           | Called with custom errors, as renderError(key, error). This function can return a message which will be wrapped in an ErrorMessage.&#xA;<br />&#xA;It can also return null to show no error.                                                                          |
| `renderWarning`        | `Function`<br/>[See signature.](#signature-renderwarning)                                             |          |           | Called with custom warnings, as renderWarning(key, warning). This function can return a message which will be wrapped in a WarningMessage.&#xA;<br />&#xA;It can also return null to show no warning.                                                                 |
| `isRequired`           | `boolean`                                                                                             |          |           | Indicates if the value is required. Shows an the "required asterisk" if so.                                                                                                                                                                                           |
| `touched`              | `boolean`                                                                                             |          |           | Indicates whether the field was touched. Errors will only be shown when the field was touched.                                                                                                                                                                        |
| `name`                 | `string`                                                                                              |          |           | Used as HTML name of the input component.                                                                                                                                                                                                                             |
| `autoComplete`         | `string`                                                                                              |          |           | Used as HTML autocomplete of the input component.                                                                                                                                                                                                                     |
| `value`                | `string`                                                                                              |    ✅    |           | Value of the input                                                                                                                                                                                                                                                    |
| `onChange`             | `ChangeEventHandler`                                                                                  |          |           | Called with an event holding the new value.                                                                                                                                                                                                                           |
| `onBlur`               | `FocusEventHandler`                                                                                   |          |           | Called when input is blurred                                                                                                                                                                                                                                          |
| `onFocus`              | `FocusEventHandler`                                                                                   |          |           | Called when input is focused                                                                                                                                                                                                                                          |
| `isAutofocussed`       | `boolean`                                                                                             |          |           | Focus the input on initial render                                                                                                                                                                                                                                     |
| `isDisabled`           | `boolean`                                                                                             |          |           | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).                                                                                                                                                                        |
| `isReadOnly`           | `boolean`                                                                                             |          |           | Indicates that the input is read only (no changes allowed).                                                                                                                                                                                                           |
| `placeholder`          | `string`                                                                                              |          |           | Placeholder text for the input                                                                                                                                                                                                                                        |
| `isCondensed`          | `boolean`                                                                                             |          |           | Use this property to reduce the paddings of the component for a ui compact variant                                                                                                                                                                                    |
| `title`                | `ReactNode`                                                                                           |    ✅    |           | Title of the label                                                                                                                                                                                                                                                    |
| `hint`                 | `ReactNode`                                                                                           |          |           | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once),&#xA;whereas description can describe it in more depth. Can also receive a hintIcon. |
| `description`          | `ReactNode`                                                                                           |          |           | Provides a description for the title.                                                                                                                                                                                                                                 |
| `onInfoButtonClick`    | `Function`<br/>[See signature.](#signature-oninfobuttonclick)                                         |          |           | Function called when info button is pressed.&#xA;<br/>&#xA;Info button will only be visible when this prop is passed.                                                                                                                                                 |
| `hintIcon`             | `ReactElement`                                                                                        |          |           | Icon to be displayed beside the hint text. Will only get rendered when hint is passed as well.                                                                                                                                                                        |
| `badge`                | `ReactNode`                                                                                           |          |           | Badge to be displayed beside the label.&#xA;<br/>&#xA;Might be used to display additional information about the content of the field (E.g verified email)                                                                                                             |

## Signatures

### Signature `renderError`

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

### Signature `renderWarning`

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

### Signature `onInfoButtonClick`

```ts
(
  event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>
) => void
```

## `data-*` props

The component further forwards all `data-` attributes to the underlying `input` component.

## `errors`

This object is a key-value map. The `renderError` prop will be called for each entry with the key and the value. The return value will be rendered inside an `ErrorMessage` component underneath the input.

The `TimeField` supports some errors out of the box. Return `undefined` from `renderError` for these and the default errors will be shown instead. This prevents consumers from having to reimplement the same error messages for known errors while still keeping the flexibility of showing custom error messages for them.

When the `key` is known, and when the value is truthy, and when `renderError` returned `undefined` for that error entry, then the `TimeField` will render an appropriate error automatically.

Known error keys are:

- `missing`: tells the user that this field is required

## Main Functions and use cases are:

- Input field for a single date

## Static methods

### `TimeField.toFieldErrors`

Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.

```ts
type FormValues = {
  myField: string;
};

<TimeField
  // ...
  name="my-field"
  errors={TimeField.toFieldErrors<FormValues>(formik.errors).myField}
/>;
```

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