A library of factory functions for writing Payload field configurations more concisely, with overrides typed from the underlying Payload field types. It covers text, number, date, relationship, upload, join, array, blocks, group, tabs and other field types, and requires Payload 3.24 or later. Helpers allow custom factories and project-wide defaults.
Opinionated factory functions for Payload CMS field configurations.
Installation
npm i payload-field-factories1
Stars
0
Forks
0
Open Issues
5 days ago
Last Updated
235
Weekly Downloads
v1.3.0
npm Version
44.5 KB
Unpacked Size
0
Dependencies
1+1 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 1 |
| Dec 4, 2026 | 1 |
| Dec 3, 2026 | 1 |
| Dec 2, 2026 | 1 |
| Dec 1, 2026 | 1 |
| Nov 30, 2026 | 1 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 1 |
| Nov 25, 2026 | 1 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
| Nov 21, 2026 | 0 |
| Nov 20, 2026 | 0 |
| Nov 19, 2026 | 0 |
| Nov 18, 2026 | 0 |
| Nov 17, 2026 | 0 |
| Nov 16, 2026 | 0 |
| Nov 15, 2026 | 0 |
| Nov 14, 2026 | 0 |
| Nov 13, 2026 | 0 |
| Nov 12, 2026 | 0 |
| Nov 11, 2026 | 0 |
| Nov 10, 2026 | 0 |
| Nov 9, 2026 | 0 |
| Nov 8, 2026 | 0 |
| Nov 7, 2026 | 0 |
| Nov 6, 2026 | 0 |
| Nov 5, 2026 | 0 |
| Nov 4, 2026 | 0 |
| Nov 3, 2026 | 0 |
| Nov 2, 2026 | 0 |
| Nov 1, 2026 | 0 |
| Oct 31, 2026 | 0 |
| Oct 30, 2026 | 0 |
| Oct 29, 2026 | 0 |
| Oct 28, 2026 | 0 |
| Oct 27, 2026 | 0 |
| Oct 26, 2026 | 0 |
| Oct 25, 2026 | 0 |
| Oct 24, 2026 | 0 |
| Oct 23, 2026 | 0 |
| Oct 22, 2026 | 0 |
| Oct 21, 2026 | 0 |
| Oct 20, 2026 | 0 |
| Oct 19, 2026 | 0 |
| Oct 18, 2026 | 0 |
| Oct 17, 2026 | 0 |
| Oct 16, 2026 | 0 |
| Oct 15, 2026 | 0 |
| Oct 14, 2026 | 0 |
| Oct 13, 2026 | 0 |
| Oct 12, 2026 | 0 |
| Oct 11, 2026 | 0 |
| Oct 10, 2026 | 0 |
| Oct 9, 2026 | 0 |
| Oct 8, 2026 | 0 |
| Oct 7, 2026 | 0 |
| Oct 6, 2026 | 0 |
| Oct 5, 2026 | 0 |
| Oct 4, 2026 | 0 |
| Oct 3, 2026 | 0 |
| Oct 2, 2026 | 0 |
| Oct 1, 2026 | 0 |
| Sep 30, 2026 | 0 |
| Sep 29, 2026 | 0 |
| Sep 28, 2026 | 0 |
| Sep 27, 2026 | 0 |
| Sep 26, 2026 | 0 |
| Sep 25, 2026 | 0 |
| Sep 24, 2026 | 0 |
| Sep 23, 2026 | 0 |
| Sep 22, 2026 | 0 |
| Sep 21, 2026 | 0 |
| Sep 20, 2026 | 0 |
| Sep 19, 2026 | 0 |
| Sep 18, 2026 | 0 |
| Sep 17, 2026 | 0 |
| Sep 16, 2026 | 0 |
| Sep 15, 2026 | 0 |
| Sep 14, 2026 | 0 |
| Sep 13, 2026 | 0 |
| Sep 12, 2026 | 0 |
| Sep 11, 2026 | 0 |
| Sep 10, 2026 | 0 |
| Sep 9, 2026 | 0 |
| Sep 8, 2026 | 0 |
| Sep 7, 2026 | 0 |
| Sep 6, 2026 | 0 |
214+199 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 214 |
| Dec 4, 2026 | 211 |
| Dec 3, 2026 | 179 |
| Dec 2, 2026 | 2 |
| Dec 1, 2026 | 14 |
| Nov 30, 2026 | 14 |
| Nov 29, 2026 | 13 |
| Nov 28, 2026 | 13 |
| Nov 27, 2026 | 14 |
| Nov 26, 2026 | 14 |
| Nov 25, 2026 | 15 |
| Nov 24, 2026 | 3 |
| Nov 23, 2026 | 4 |
| Nov 22, 2026 | 6 |
| Nov 21, 2026 | 6 |
| Nov 20, 2026 | 4 |
| Nov 19, 2026 | 10 |
| Nov 18, 2026 | 17 |
| Nov 17, 2026 | 17 |
| Nov 16, 2026 | 16 |
| Nov 15, 2026 | 18 |
| Nov 14, 2026 | 18 |
| Nov 13, 2026 | 22 |
| Nov 12, 2026 | 26 |
| Nov 11, 2026 | 18 |
| Nov 10, 2026 | 18 |
| Nov 9, 2026 | 20 |
| Nov 8, 2026 | 17 |
| Nov 7, 2026 | 18 |
| Nov 6, 2026 | 14 |
| Nov 5, 2026 | 4 |
| Nov 4, 2026 | 5 |
| Nov 3, 2026 | 6 |
| Nov 2, 2026 | 7 |
| Nov 1, 2026 | 7 |
| Oct 31, 2026 | 6 |
| Oct 30, 2026 | 6 |
| Oct 29, 2026 | 6 |
| Oct 28, 2026 | 5 |
| Oct 27, 2026 | 4 |
| Oct 26, 2026 | 3 |
| Oct 25, 2026 | 2 |
| Oct 24, 2026 | 2 |
| Oct 23, 2026 | 2 |
| Oct 22, 2026 | 5 |
| Oct 21, 2026 | 5 |
| Oct 20, 2026 | 5 |
| Oct 19, 2026 | 3 |
| Oct 18, 2026 | 4 |
| Oct 17, 2026 | 5 |
| Oct 16, 2026 | 5 |
| Oct 15, 2026 | 3 |
| Oct 14, 2026 | 10 |
| Oct 13, 2026 | 10 |
| Oct 12, 2026 | 10 |
| Oct 11, 2026 | 10 |
| Oct 10, 2026 | 9 |
| Oct 9, 2026 | 9 |
| Oct 8, 2026 | 8 |
| Oct 7, 2026 | 3 |
| Oct 6, 2026 | 3 |
| Oct 5, 2026 | 3 |
| Oct 4, 2026 | 2 |
| Oct 3, 2026 | 5 |
| Oct 2, 2026 | 10 |
| Oct 1, 2026 | 10 |
| Sep 30, 2026 | 8 |
| Sep 29, 2026 | 17 |
| Sep 28, 2026 | 17 |
| Sep 27, 2026 | 18 |
| Sep 26, 2026 | 18 |
| Sep 25, 2026 | 14 |
| Sep 24, 2026 | 15 |
| Sep 23, 2026 | 16 |
| Sep 22, 2026 | 16 |
| Sep 21, 2026 | 17 |
| Sep 20, 2026 | 17 |
| Sep 19, 2026 | 14 |
| Sep 18, 2026 | 17 |
| Sep 17, 2026 | 20 |
| Sep 16, 2026 | 21 |
| Sep 15, 2026 | 12 |
| Sep 14, 2026 | 13 |
| Sep 13, 2026 | 12 |
| Sep 12, 2026 | 12 |
| Sep 11, 2026 | 8 |
| Sep 10, 2026 | 4 |
| Sep 9, 2026 | 7 |
| Sep 8, 2026 | 8 |
| Sep 7, 2026 | 15 |
| Sep 6, 2026 | 15 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1175876504-root)<a href="https://payloaddirectory.dev/plugins/1175876504-root"><img src="https://payloaddirectory.dev/badge/1175876504-root.svg" alt="Payload Directory"></a>README
Opinionated factory functions for Payload CMS field configurations. Type-safe, concise, and composable.
npm install payload-field-factories
import {
dateField,
groupField,
relationshipField,
richTextField,
tab,
tabsField,
textField,
} from 'payload-field-factories';
const fields = [
textField('title', {required: true, localized: true}),
textField('tags', {hasMany: true}),
relationshipField('author', 'users'),
dateField('publishedAt'),
groupField('address', [
textField('street'),
textField('city'),
]),
tabsField([
tab('content', [richTextField('body')]), // named tab
tab({en: 'Meta'}, [textField('slug')]), // unnamed tab
]),
];
The override type is derived from the Payload field type with required args omitted, giving you full type safety and autocompletion. There are two calling patterns:
Fields identified by just a name take the name as their only required argument, followed by an optional overrides
object:
textField('title', {required: true, localized: true});
numberField('price');
Fields that also need child fields or options take that content as their second argument (or as the only argument
for rowField, tabsField, and unnamed groupField). Pass it directly as a shortcut, or pass an object with the
content plus overrides when you need to tweak the field:
// array — name + fields
arrayField('items', [textField('label')]);
arrayField('items', {fields: [textField('label')], overrides: {minRows: 1}});
// blocks — name + block references
blocksField('content', ['hero', 'cta']);
blocksField('content', {blockReferences: ['hero', 'cta'], overrides: {minRows: 1}});
blocksField('content', {blocks: [heroBlock], overrides: {minRows: 1}}); // inline blocks instead of references
// radio — name + options
radioField('size', ['sm', 'md', 'lg']);
radioField('size', {options: ['sm', 'md', 'lg'], overrides: {defaultValue: 'md'}});
// select — name + options
selectField('status', ['draft', 'published']);
selectField('tags', {options: ['news', 'blog'], overrides: {hasMany: true}});
// group — name + fields (name optional)
groupField('address', [textField('street'), textField('city')]);
groupField('address', {fields: [textField('street')], overrides: {localized: true}});
groupField([textField('street')]); // unnamed
// ui — name + components
uiField('preview', {Field: '/components/Preview'});
uiField('preview', {components: {Field: '/components/Preview'}, overrides: {admin: {position: 'sidebar'}}});
// collapsible — label + fields
collapsibleField('Advanced', [textField('slug')]);
collapsibleField('Advanced', {fields: [textField('slug')], overrides: {admin: {initCollapsed: true}}});
// row — fields only
rowField([textField('firstName'), textField('lastName')]);
rowField({fields: [textField('firstName'), textField('lastName')], overrides: {admin: {readOnly: true}}});
// tabs — tabs only
tabsField([tab('content', [richTextField('body')])]);
tabsField({tabs: [tab('content', [richTextField('body')])], overrides: {label: 'Sections'}});
// tab — name + fields (named, label goes in overrides) or label + fields (unnamed)
tab('content', [richTextField('body')]);
tab('content', {fields: [richTextField('body')], overrides: {label: 'Content'}});
tab({en: 'Meta', de: 'Meta'}, [textField('slug')]); // unnamed
Relationship, upload and join fields take their targets as positional arguments:
relationshipField('author', 'users');
relationshipField('related', ['posts', 'pages'], {hasMany: true});
uploadField('image', 'media');
joinField('posts', 'posts', 'author'); // name, collection, on
hasMany is typed via overloads on textField, numberField, selectField, relationshipField and
uploadField: without hasMany (or hasMany: false) you get the single variant (e.g. RelationshipFieldSingle), with
hasMany: true the many variant (RelationshipFieldMany, which allows minRows/maxRows). A hasMany that is only
known as boolean at runtime returns the union (RelationshipField).
const hasMany: boolean = config.multiple;
relationshipField('tags', 'tags', {hasMany}); // RelationshipField
dateField, dateTimeField and timeField set the picker appearance and German formats:
| Factory | pickerAppearance | displayFormat | timeFormat | timeIntervals |
|---|---|---|---|---|
dateField | dayOnly | dd.MM.yyyy | – | – |
dateTimeField | dayAndTime | dd.MM.yyyy HH:mm | HH:mm | 5 |
timeField | timeOnly | HH:mm | HH:mm | 5 |
Keys in admin.date are merged over these defaults per call; pickerAppearance is fixed by the factory. For
project-wide formats use createFieldFactories (see Project-wide defaults).
dateTimeField('startsAt', {admin: {date: {displayFormat: 'yyyy-MM-dd HH:mm', timeIntervals: 15}}});
textField textareaField emailField numberField checkboxField dateField dateTimeField timeField
codeField jsonField richTextField pointField radioField selectField uploadField relationshipField
joinField arrayField blocksField rowField groupField collapsibleField tabsField tab uiField
Helpers: createFieldFactories mergeOverrides removeUndefinedDeep
Each factory exports its overrides type (TextFieldOverrides, DateFieldOverrides, …); factories with hasMany also
export …Single/…Many field and overrides types.
mergeOverrides(defaults, overrides, {enforced}?) builds your factory's config from three layers, without mutating
any of them: defaults (the caller may change them) → overrides (passed by the caller) → enforced (the caller
cannot change them). Each layer is laid over the previous one with the same rules:
undefined values in overrides and enforced are ignored; top-level keys from the later layer win.access, admin, admin.components, admin.date and custom are merged one level deep, the later layer wins per
key. Passing only access.read keeps your access.update; passing only admin.components.Description keeps your
Field. Arrays such as beforeInput/afterInput and anything deeper are replaced.hooks are concatenated per hook name in layer order: defaults hooks, caller hooks, enforced hooks. Put a hook
that must run first into defaults, one that must run last into enforced.labels, validate, filterOptions, admin.condition …) is replaced.The built-in factories don't use it: an admin passed to them replaces their defaults.
export const mailToField = (name: string, overrides?: Partial<Omit<TextField, 'type' | 'name'>>) =>
textField(
name,
mergeOverrides({admin: {placeholder: 'mailto:…'}}, overrides, {
enforced: {validate: validateMailto, hooks: {beforeValidate: [appendMailto]}}, // runs after caller hooks
}),
);
createFieldFactories(config) returns all factories with project-wide defaults; without config it returns the
originals. Values passed per call always win (label: false too). The returned factories keep their overload types.
label: (name) => label sets the label of every named field without its own label. Factories without a name
(rowField, tabsField, collapsibleField, unnamed groupField/tab) and uiField stay unchanged.date, dateTime, time are merged into admin.date of dateField, dateTimeField and timeField, over the
built-in defaults (dd.MM.yyyy, dd.MM.yyyy HH:mm, HH:mm, interval 5).const t = createTranslator('collections:events');
const {textField, dateField} = createFieldFactories({label: name => t(name), date: {displayFormat: 'yyyy-MM-dd'}});
textField('title'); // label: t('title')
textField('slug', {label: false}); // no label
dateField('startDate', {admin: {date: {displayFormat: 'MM/yyyy'}}}); // per call wins
MIT
payload schema
Define Payload field validation once and compile it to Payload fields and Zod 4 schemas
7139/wk3v3
payload utilities
Helper functions for composing field validators, extracting IDs and resolving documents in Payload
77251/wk0v3
payload utilities
Developer utilities for traversing, flattening and transforming Payload documents and tidying generated types
6229/wk16v3
payload plugin tooling
Shared lint, format, TypeScript, build, test and CI config for developing Payload plugins
6039/wk0v4
payload cli
Command-line access to Payload collections and globals through the Local API, built for AI agents and humans
588/wk13v3
payload dev tools
Floating dev toolbar, /dev pages and an app snapshot for AI agents in Payload projects on Next.js
5548/wk18v3