Concepts
Element data
Element data concepts for Built.js themes and plugins.
An Element represents a reusable UI component. Some examples are:
- Button
- Link
- Card
In a theme or plugin Next.js project, there are 4 things you need to do to create an element:
Create a React component
This is done in the components/elements
directory.
Configure element data
This will make the element data configurable in the end site's Sanity CMS. Configure this in public/data/schemas/elements
.
Configure a section to use the element
Do this in public/data/sections.json
.
Use the React element in your section template code
The component is ready to use in your code and data will be available for it to use.
Here's an example of a button element:
And the data for it:
Now this element can be used in a template data:
And in the template Next.js component, you can now use the element like this: