Union schema
Learn how to combine multiple schemas into one.
Union schemas allow you to define a schema that can be one of several types, useful for components with multiple variations.
The input for a union schema is a drop-down menu that allows you to select one of the possible types, each with its own set of fields.
Examples
Below is an example of a union schema:
{"type": "union","types": {"text-hero": {"type": "reference","id": "text-hero"},"image-hero": {"type": "reference","id": "image-hero"}}}
Keep in mind that the text-hero and image-hero components are just examples for demonstration purposes, and you can use any components available to you.
Properties
The union schema is straightforward and only have one specific property that maps component IDs to their reference schemas.
The keys of the types object must match the IDs of the components referenced. Otherwise, the schema is considered invalid.
The following list describes the properties of union schemas:
- titlestring
The title of the union, up to 60 characters.
This value is used as the label in lists and component selectors.
- descriptionstring
The description of the union, up to 160 characters.
You can use this description to provide additional details about the types available. It supports basic Markdown formatting, including:
- Bold: To make text bold, enclose it in double asterisks. For example, **Bold** displays Bold.
- Italic: To italicize text, enclose it in single asterisks. For example, *Italic* appears as Italic.
- Code: To display text in a monospaced font, enclose it in backticks. For example, code displays code.
- Link: To create links, use square brackets followed by parentheses. For example, [Croct](https://croct.com) becomes Croct.
- typestring
The type of the schema. Always union for union schemas.
- typesobject<string,Reference>
The mapping of component IDs to their reference schemas, limited to 10 components.