# Schema reference

Learn key concepts about schemas.

A schema is a structured JSON format that specifies the shape of your [Content](/reference/content/definition/introduction).

When you use the visual interface, a schema is automatically generated under the hood. This schema-first approach allows you to define your content visually or through a JSON file, depending on your preference.

## Component

Components are reusable schemas for your content.

When you create a component, you are giving a unique name to a [top-level schema](#top-level-schemas), which you can then reference in other schemas.

For more information, check out our guide on [Components](/explanation/component).

## Top-level schemas

Top-level schemas are those you can use to define components.

Currently, you can only create components for [structures](/reference/content/schema/types/structure) and [unions](/reference/content/schema/types/union). Other types, like text, number, boolean, and list, are not yet supported as top-level schemas.

## Schema types

Each schema has an associated type that determines the kind of data it describes.

These are the available schema types:

- **Number**: Numeric values, such as prices, quantities, and percentages.
- **Boolean**: True or false values, such as on/off or yes/no switches.
- **Text**: Textual values, such as titles, descriptions, and paragraphs.
- **List**: Collections of items such as lists of tags, images, or products.
- **Structure**: A group of attributes, such as a button's label and link.
- **Reference**: A reference to an external schema or component.
- **Union**: Multiple schemas combined into a single type.

> **Question: How about other types available in the interface?**
>
> All the types you see in the interface are configurations of the basic types.
>
> For example, an Enumeration is a [text schema](/reference/content/schema/types/text) with the [`choices`](/reference/content/schema/types/text#choices-prop) property configured. The same goes for the Color, URL and File types.

For more information about these and other types, see [Schema types](/reference/content/schema/types).

## Constraints

We enforce some constraints on content schemas to ensure that components remain performant and manageable as your content model evolves.

These constraints include:

- Up to 30 attributes per structure
- Nesting up to 6 levels deep
- Maximum of 10 components in a union
- Maximum complexity score of 50.

> **Deep dive: What is a complexity score?**
>
> The complexity score tells how complex a component is based on its structure and attributes. The higher the score, the more complex the component.
>
> To calculate the score, start with 0 and then add up the complexity of the component's attributes as follows:
>
> - **Structures**\
>   Count 1 for the structure itself, and add the complexity of its attributes.
> - **Lists**\
>   Count 1 for the list itself, and add the complexity of its item type.
> - **Primitives**\
>   Count 1 for each primitive type (text, boolean, and number).
> - **Unions**\
>   Add the complexity of the most complex component in the union.
> - **References**\
>   Add the complexity of the referenced component.
>
> Now let's apply this to an example. Suppose we have a product listing component that contains a list of products. Each product has a title, an image, and a price. The complexity of the component would be calculated as follows:
>
> - Count 1 for the list
> - Count 1 for the product structure
> - Count 1 for each of the product attributes (title, image, and price).
>
> That gives us a **complexity score of 5**.

For best practices on designing components, see our [Best practices](/immersion/guides/designing-components/best-practices) guide.

## Explore

- [Schema types](/reference/content/schema/types): Discover the different types available for structuring your content.
- [Components](/explanation/component): Read more about reusing schemas with components.
- [Best practices](/immersion/guides/designing-components/best-practices): Explore the best practices for designing components.
- [Content reference](/reference/content/definition/introduction): Learn how to define content once you have specified your schema.
