Components
This article explains how to create a component in Prepr. A component is a predefined set of fields that can be used in models.
Create a component
To create a component, follow these steps:
- Click the Schema tab to open the Schema Editor.
- Then, click the + Create component button.
- Name the component as follows Or import a component:
General fields | Description |
---|---|
Display name | Choose a unique name for the component. |
Type name | The value of this field is automatically generated. This field is important for the GraphQL API to connect your front-end to Prepr. When you create a new component, this name is generated as follows: PascalCase version of the Display name, stripped of all non-alphanumeric characters. For example, the component name "SEO tags" generates SEOTags. |
Icon | Choose an icon image that visually represents your component. This is used for the dynamic content editor and other parts of the content item editor interface. |
After creating a component, you can include a component in a model. The following model fields allow you to use your component in a model:
- Component field: This field type allows the model to include the component.
- Dynamic content field: This field type allows the component fields to be available in the Dynamic Content Editor. Check out the dynamic content field type for more details.
- Stack field: This field type allows the model to include multiple components and models.
Tip
Create empty components to serve as placeholders. This way you can trigger the front-end to insert static front-end components, such as banners, marketing widgets, or forms. An empty component is a component without any fields. All empty components in a dynamic content field are shown as a label so you can easily recognize them.
See an example empty component used as a placeholder, below:
Note
When someone else is working on the same schema, for example, they add a new component or delete an existing component, you'll see those changes in real-time within the schema editor.
Add fields to a component
To add fields to your component, follow these steps:
- Click the Schema tab to open the Schema Editor.
- Click on the component from the list of models on the left.
- Drag and drop the desired field type, for example, Text,
For a complete list and all the specs, check out all Prepr field types.
Let's look at some basic settings that are common across all field types.
- Using Text as an example, name it as follows:
General fields | Description |
---|---|
Display name | The field label shown in the content editing interface. |
ID | The value of this field is automatically generated. The technical ID of this field that is used, for example, to retrieve content through the API. |
For more details on the other Text settings, check out the text field type.
- Click the Appearance tab to set the appearance options for the field.
Appearance fields | Description |
---|---|
Help text | An instruction to help content editors. Make instructions clearer by making text bold, italic, or bolditalic. Use the following standard Markdown syntax: *. and _ (italic) ** and __ (bold) *** and ___ (bolditalic). |
Show in preview (deprecated) | Enable this option to make the field visible in the preview , which can be accessed using the Preview button in the sidebar of the content item editing interface. Note: From April 24th, 2023, the Preview button is no longer available for new Prepr accounts created after this date. To review your content before publishing, please set up a review URL on a model. Learn more |
Disable editing | Activate this option if you don't want a content editor to edit this field. For example, when this field is only supposed to be edited through an API or content automation. |
- Click the Validation tab to set up validation rules for the field.
Enable This field is required if this is a mandatory field. The validation only triggers when a content item is set to the Done status. For more details, check out Content item statuses.
For more details on the other Text validation options, check out the text field type.
Note
Warning
Add columns
You can also use columns to determine the display of the fields in your content item. Columns are used to divide fixed content item fields into a maximum of three columns.
To add columns, follow these steps:
- Click the Schema tab to open the Schema Editor.
- Click on the component from the list of components on the left.
- Click the + Columns button.
- Drag the column element above the fields that you want divided into columns.
- Choose the number of columns that you want those fields to be grouped into.
Create a nested component
Note
Nested components can be added to models directly or to a Stack field. When adding a nested component to a Dynamic content field, only the parent component will be visible. Child components will be hidden.
This feature allows you to add an individual (child) component into another (parent) component, creating nested levels of content. You can reuse individual components as many times as needed, even if they're already used within nested components. For example, you can use a call-to-action component in both a page header component and a product collection component.
To create a nested component, follow these steps:
-
Create individual components which represent different elements in your page layout, such as header, image and text, call-to-action, product or article collections, etc.
-
Determine a parent component – the one you’ll be using as a container for other components (child components). Click to open its configuration.
-
From the parent component page, add a new component field and select the needed child component. Save your choice.
Now that you have created the nested component, you can add it to a model directly or place it within a Stack field.
Export and import a component
To export a component, follow these steps:
- Click the Schema tab to open the Schema Editor.
- Click on a component from the list of components on the left.
- Click on the button at the top of the component.
- Click Export component to download a JSON file of the component.
To import a component, follow these steps:
- Click the Schema tab to open the Schema Editor.
- Then, click the + Create component button.
- Click Or import a component.
- Choose the JSON file of the component that you want to import.
Export and import components when you want to use a component from one environment in another environment, for example, export a component from your staging environment and import the component into your production environment.