Field Types Reference
This reference documents all field types available in Trokky schemas.
Common Properties
Section titled “Common Properties”All field types share these properties:
| Property | Type | Description |
|---|---|---|
name | string | Unique field identifier |
type | string | Field type |
title | string | Display label |
description | string | Help text |
required | boolean | Whether field must have a value |
hidden | boolean | function | Hide from Studio |
readOnly | boolean | function | Prevent editing |
default | any | Default value |
group | string | Field group name |
validation | object | Validation rules |
String
Section titled “String”Single-line text input.
{ name: 'title', type: 'string', title: 'Title', required: true, validation: { min: 1, max: 200, },}Validation Options
Section titled “Validation Options”| Option | Type | Description |
|---|---|---|
min | number | Minimum length |
max | number | Maximum length |
pattern | string | Regex pattern |
email | boolean | Validate as email |
url | boolean | Validate as URL |
Examples
Section titled “Examples”// Email field{ name: 'email', type: 'string', validation: { email: true },}
// URL field{ name: 'website', type: 'string', validation: { url: true },}
// Pattern validation{ name: 'code', type: 'string', validation: { pattern: '^[A-Z]{3}-\\d{4}$' },}Multi-line text area.
{ name: 'description', type: 'text', title: 'Description', rows: 4,}Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
rows | number | 3 | Visible rows |
Number
Section titled “Number”Numeric input.
{ name: 'price', type: 'number', title: 'Price', validation: { min: 0, max: 10000, precision: 2, },}Validation Options
Section titled “Validation Options”| Option | Type | Description |
|---|---|---|
min | number | Minimum value |
max | number | Maximum value |
integer | boolean | Must be integer |
precision | number | Decimal places |
positive | boolean | Must be positive |
Boolean
Section titled “Boolean”Toggle switch or checkbox.
{ name: 'featured', type: 'boolean', title: 'Featured', default: false,}Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
layout | string | 'switch' | 'switch' or 'checkbox' |
Date picker (no time).
{ name: 'birthday', type: 'date', title: 'Birthday',}Stored Format: YYYY-MM-DD
DateTime
Section titled “DateTime”Date and time picker.
{ name: 'publishedAt', type: 'datetime', title: 'Published At',}Stored Format: ISO 8601 (2024-01-15T10:30:00.000Z)
Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
timezone | string | Default timezone |
URL-friendly identifier.
{ name: 'slug', type: 'slug', title: 'Slug', options: { source: 'title', maxLength: 96, },}Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
source | string | - | Field to generate from |
maxLength | number | 200 | Maximum length |
isUnique | boolean | false | Check uniqueness |
Stored Format:
{ "current": "my-blog-post", "_type": "slug"}Rich Text
Section titled “Rich Text”WYSIWYG editor for formatted content.
{ name: 'content', type: 'richtext', title: 'Content',}Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
styles | array | Allowed block styles |
lists | array | Allowed list types |
marks | array | Allowed inline marks |
annotations | array | Custom annotations |
{ name: 'content', type: 'richtext', options: { styles: ['normal', 'h1', 'h2', 'h3', 'blockquote'], lists: ['bullet', 'number'], marks: ['bold', 'italic', 'underline', 'link'], },}Image or file upload.
{ name: 'featuredImage', type: 'media', title: 'Featured Image', options: { accept: ['image/*'], maxSize: 5 * 1024 * 1024, },}Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
accept | string[] | Allowed MIME types |
maxSize | number | Max file size in bytes |
showVariants | boolean | Show variant selector |
showMetadata | boolean | Show metadata editor |
requireAlt | boolean | Require alt text |
Stored Format:
{ "_type": "media", "_ref": "media-abc123", "alt": "Image description"}Reference
Section titled “Reference”Link to another document.
{ name: 'author', type: 'reference', title: 'Author', options: { to: 'author', },}Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
to | string | string[] | Target schema(s) |
filter | object | Filter available documents |
// Single type reference{ name: 'author', type: 'reference', options: { to: 'author' },}
// Multiple type reference{ name: 'related', type: 'reference', options: { to: ['post', 'page'] },}
// Filtered reference{ name: 'publishedPost', type: 'reference', options: { to: 'post', filter: { status: 'published' }, },}Stored Format:
{ "_type": "reference", "_ref": "author-abc123"}Object
Section titled “Object”Nested structure with fields.
{ name: 'seo', type: 'object', title: 'SEO Settings', fields: [ { name: 'metaTitle', type: 'string', title: 'Meta Title' }, { name: 'metaDescription', type: 'text', title: 'Meta Description' }, { name: 'ogImage', type: 'media', title: 'OG Image' }, ],}Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
collapsible | boolean | Can collapse in Studio |
collapsed | boolean | Initially collapsed |
Stored Format:
{ "seo": { "metaTitle": "Page Title", "metaDescription": "Description here", "ogImage": { "_ref": "media-xyz" } }}List of items.
// Array of strings{ name: 'tags', type: 'array', title: 'Tags', of: [{ type: 'string' }],}
// Array of objects{ name: 'links', type: 'array', title: 'Links', of: [ { type: 'object', fields: [ { name: 'label', type: 'string' }, { name: 'url', type: 'string' }, ], }, ],}
// Array of references{ name: 'relatedPosts', type: 'array', title: 'Related Posts', of: [{ type: 'reference', options: { to: 'post' } }],}Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
of | array | Item types |
sortable | boolean | Enable drag-sort |
layout | string | 'list' or 'grid' |
Validation
Section titled “Validation”{ name: 'tags', type: 'array', of: [{ type: 'string' }], validation: { min: 1, max: 10, unique: true, },}Select
Section titled “Select”Predefined options.
{ name: 'status', type: 'select', title: 'Status', options: { list: [ { value: 'draft', title: 'Draft' }, { value: 'review', title: 'In Review' }, { value: 'published', title: 'Published' }, ], },}Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
list | array | Option items |
layout | string | 'dropdown' or 'radio' |
Conditional Fields
Section titled “Conditional Fields”Hidden
Section titled “Hidden”{ name: 'externalUrl', type: 'string', hidden: ({ document }) => document.linkType !== 'external',}Read-Only
Section titled “Read-Only”{ name: 'slug', type: 'slug', readOnly: ({ currentUser }) => currentUser.role !== 'admin',}Custom Validation
Section titled “Custom Validation”{ name: 'title', type: 'string', validation: { custom: (value, { document }) => { if (document.status === 'published' && !value) { return 'Title is required for published documents'; } return true; }, },}TypeScript Types
Section titled “TypeScript Types”import type { Field, StringField, ReferenceField } from '@trokky/core';
const titleField: StringField = { name: 'title', type: 'string', required: true,};
const authorField: ReferenceField = { name: 'author', type: 'reference', options: { to: 'author' },};Next Steps
Section titled “Next Steps”- Schema Types Reference - Schema structure
- Defining Schemas Guide - Best practices
- Configuration Reference - Full options