Text
Last updated

A text field in the Page Builder.
The text field allows content writers to provide plain text.
Text field values can be used like a string in JavaScript.
<p>My name: {slice.primary.name}</p>Add a text field to a content model
Text fields are added using the Type Builder, a tool for building by hand, or the Prismic CLI, a tool for AI agents.
Watch for changes
In your local website project, start the Prismic CLI’s
synccommand. The CLI will watch for changes in the Type Builder and pull them into your project.npx prismic sync --watchAdd a text field
In the Type Builder, navigate to the slice, page type, or custom type you want to modify. Add a text field and provide the following:
- Label: The label shown to content writers in the Page Builder. Use an easily understandable name.
- API ID: The property name in the Content API. Use a short, snake-cased name.
You can now close the Prismic CLI
synccommand or add your next field.
Add a text field
Use the
prismic field add textcommand to add a text field to a slice.npx prismic field add text title --to-slice MySliceUse
--to-typeto add the field to a page type or custom type instead.npx prismic field add text title --to-type page
Open Slice Machine
In your Prismic project, start Slice Machine to begin editing content models.
npx start-slicemachine --openAdd a text field
In Slice Machine, navigate to the slice, page type, or custom type you want to modify. Add a text field.
The label determines the label shown to content writers in the Page Builder. Use an easily understandable name.
The API ID determines the property name in the Content API. Use a short, snake-cased name.
Use text fields
Text fields can be used like a string in JavaScript.
<p>My name: {slice.primary.name}</p>Check if a text field has a value
Use isFilled.keyText() from @prismicio/client to check if a text field has a value.
import { isFilled } from "@prismicio/client";
if (isFilled.keyText(slice.primary.my_text_field)) {
// Do something if `my_text_field` has a value.
}Learn more about isFilled
API response
Here is what a text field looks like from the Content API:
{
"example_text": "Lorem ipsum"
}