Text
This article explains what the text field is and how to configure it.
The text field allows content writers to provide plain text.
Add a text field to a content model
Open Slice Machine
In your Prismic project, start Slice Machine to begin editing content models.
npx start-slicemachine --open
Add 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 understood name.
The API ID determines the property name in the Document 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>
Tips
Use
isFilled.text()
to check if a text field has a valueimport { isFilled } from "@prismicio/client"; if (isFilled.text(slice.primary.my_text_field)) { // Do something if `my_text_field` has a value. }
API response
Here is what a text field looks like from the Document API:
{
"example_text": "Lorem ipsum"
}