Tina Docs
Introduction
Overview
Introduction To TinaCMS
Getting Started
Using the Tina Editor
FAQ
Core Concepts
Content Modeling
Data Fetching
Visual Editing
Querying Content
Overview
Writing custom queries
Editing
Overview
Markdown & MDX
Block-based editing
Single Document Collections
Customizing Tina
Overview
Validation
Custom Field Components
Custom List Rendering
Format and Parse Input
Filename Customization
Before Submit function
Going To Production
Overview
Tina Cloud
Self-Hosted
Drafts
Overview
Draft Fields
Editorial Workflow
Guides
Overview
Framework Guides
Separate Content Repo
Querying Tina Content at Runtime
Internationalization
Migrating From Forestry
Further Reference
Overview
Config
Schema
Overview
Collections
Fields
Templates
Field Types
Overview
string
number
datetime
boolean
image
reference
object
rich-text
The "tina" folder
The TinaCMS CLI
Media
Search
Content API
Tina's edit state
The "tinaField" helper
Self-Hosted Components

string Type

type StringField = {
label: string
name: string
type: 'string'
list?: boolean
options?: (string | { value: string; label: string })[]
// Represents the "body" of a markdown file
isBody?: boolean
// See https://tina.io/docs/extending-tina/overview/ for customizing the UI
ui?: {
label?: string
description?: string
component?: FC<any> | string | null
parse?: (value: string | string[], name: string, field: F) => any
format?: (value: string | string[], name: string, field: F) => any
// defaultItem can only can be used when {list: true}
defaultItem?: () => string | string
validate?(
// string or string[] depends on list true or false
value: string | string[],
allValues: any,
meta: any,
field: UIField<F, Shape>
): string | undefined | void
}
}

Examples

Tina will generate the appropriate component depending on the configuration provided.

Simple

{
type: 'string',
name: 'title',
label: 'Title'
}

Simple w/ List

Setting list: true will make the value an array

{
type: 'string',
name: 'title',
label: 'Title',
list: true
}

As a list w/ options

Setting list: true and providing options will make the value an array with a selection list

{
type: 'string',
name: 'title',
label: 'Title',
list: true,
options: [
{
value: "movies",
label: "Movies"
}, {
value: "music",
label: "Music"
}
]
}

Using the isBody property

When working with markdown, you can indicate that a given field should represent the markdown body

{
type: 'string',
name: 'body',
label: 'Body',
// Indicates this field should repesent the file's body
isBody: true
}

Override the built-in component

By default, the text field is used for strings. To use a different core field plugin, specify it with the ui.component property

{
label: "Description",
name: "description",
type: "string",
ui: {
component: "textarea"
}
}

Providing a custom component

You can create your own components

{
label: "Title",
name: "title",
type: "string",
ui: {
component: ({ input }) => {
return (
<div>
<label htmlFor="title">Title: </label>
<input {...input}></input>
</div>
);
},
},
}

Last Edited: September 12, 2024

Product

Showcase
TinaCloud
Introduction
How Tina Works
Roadmap

Resources

Blog
Examples
Support
Media

Whats New
TinaCMS
TinaCloud
Use Cases
Agencies
Documentation
Teams
Jamstack CMS
Benefits
MDX
Markdown
Git
Editorial Workflow
Customization
SEO
Comparisons
TinaCMS vs Storyblok
TinaCMS vs Sanity
TinaCMS vs DecapCMS
TinaCMS vs Contentful
TinaCMS vs Builder.io
TinaCMS vs Strapi
Integrations
Astro
Hugo
NextJS
Jekyll