What are Custom Types?

Prismic natively supports custom types. Custom types allow you to define and configure fields for your content. Some examples of custom types are pages, posts, articles, authors, recipes, events, products… whatever blocks of content you need for your specific project.

There are two categories of custom types: Repeatable Types and Single Types. Repeatable types are for content that you will have more than one of, such as articles, products, places, authors, etc. Single Types are for content that you only need one instance of, such as a homepage or a privacy policy page. If you define a custom type as a Single Type, you will only be allowed to create one instance of it.

Custom types are created by selecting the category as either repeatable or single, then using a drag-and-drop builder to add content fields to the custom type. You simply add and configure the fields you need for that certain content type. A variety of fields are available to add to your custom types, including Rich Text, Images, Dates, Numbers, etc.

Let’s walk through how to setup a custom type.

Creating a new custom type

Go to the Custom types page. If you do not yet have any custom types in your repository, you will be taken directly to the new custom type page. If you already have custom types in your repository, then you will see a list of your custom types. Click on “New” to create a new type.

Here you will configure your custom type as either a Repeatable Type or a Single Type. If you select Repeatable Type, you can create as many instances of the custom type as you need. If you select Single Type, you will only be able to create one instance of this custom type.

You will also need to enter a name for the custom type. When you enter the name, Prismic will automatically assign the custom type an API-ID.

When you click the “Create new custom type” button, your type will be created and you will be taken to the custom type builder to begin adding and configuring the content fields.

Adding and defining your content fields

The Prismic drag-and-drop builder makes it easy to construct your custom types. Simply drag the content field you want from the panel on the right and drop it in where you want it on the left.

When you add a new field, the field configuration panel will appear. Here you can modify the field’s settings including the Field Name, the API ID, and other field specific options.

If you need to modify a field’s settings later, you can hover over the field, and click on the gear icon to update the field’s options.

You can organize your fields however you like. You are able to rearrange the order of the fields and can even put your fields into different tabs. This allows you to organize them the way that makes it easiest for your content writers to fill in with content.   

The “Add a new tab” button can be found at the top the page and will create a new space to drag and drop your fields onto.

The Custom Type drag-and-drop builder is still in beta and doesn’t include all the advanced options for every field. To include or modify advanced settings, use the JSON editor.  You can switch between the drag-and-drop Build mode and the JSON editor at the top of the page. 

For more information about the available content fields and their available options, refer to the documentation for each field.

Using Slices in Custom Types

Slices are a powerful tool for custom types. They allow you to define a dynamic zone for richer page layouts. 

For example in a blog post, defining a Slice zone allows the writer to choose between adding a text section, an image, or a quote. This gives the writer the freedom to compose the blog post by alternating and ordering as many of these choices as they want/need.

You can discover more about slices and how to integrate them into your custom type on the Slices page. 

Did this answer your question?