# 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.

![Union form](/assets/reference/content/schema/union.png)

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:

```json
{
 "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.

> **Component ID pairing**
>
> 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:

- `title`: `string`

  The title of the union, up to 60 characters.

  This value is used as the label in lists and component selectors.

- `description`: `string`

  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](https://croct.com).

- `type`: `string`

  The type of the schema. Always `union` for union schemas.

- `types`: `Record<string, Reference>` (see [Reference](reference))

  The mapping of component IDs to their [reference schemas](/reference/content/schema/types/reference#properties), limited to 10 components.
