# Text schema

Learn how to define schemas for textual values.

Text schemas describe textual values such as titles, colors, and URLs.

![Text input](/assets/reference/content/schema/text.png)

The input for a text schema can take the form of a text field, text area, color input, or even a select box, depending on the schema configuration.

## Examples

Below are some examples of text schemas:

**Text**

```json
{
  "type": "text"
}
```

**Color**

```json
{
  "type": "text",
  "format": "color"
}
```

**URL**

```json
{
  "type": "text",
  "format": "url"
}
```

**Enumeration**

```json
{
  "type": "text",
  "choices": {
    "left": {
      "label": "Left"
    },
    "center": {
      "label": "Center"
    },
    "right": {
      "label": "Right"
    }
  }
}
```

## Properties

Text schemas offer several properties that allow you to customize input validation and presentation, but not all of them can be used together.

> **Mutually exclusive properties**
>
> The properties `format` and `choices` cannot be used together with any other properties except for `type`.

The following list describes the properties of text schemas:

- `type`: `string`

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

- `minimumLength`: `number` (optional)

  The minimum length of the text.

- `maximumLength`: `number` (optional) (default: maximum allowed)

  The maximum length of the text.

  > **Maximum length**
  >
  > The maximum length is limited to 300 characters for single-line text and 1000 characters for multi-line text and URLs.

- `format`: `string` (optional)

  The format the text must follow as listed below:

  | Format      | Description                                                                |
  | ----------- | -------------------------------------------------------------------------- |
  | `multiline` | A multi-line text, displayed as a text area.                               |
  | `color`     | A hexadecimal color code, such as `#ff0000` or `#f00`.                     |
  | `url`       | A URL as defined by the [URL specification](https://url.spec.whatwg.org/). |

- `pattern`: `string` (optional)

  A regular expression the text must match, without delimiters and up to 100 characters. For example, `^[a-z0-9]+$` to only allow lowercase letters and numbers.

- `choices`: `Record<string, Choice>` (optional) (see [Choice](#choice-props))

  A map of possible values for the text, limited to 20 choices.

  The keys are the values, and the values are the choice definitions as described below.

  - `label`: `string` (optional) (default: the choice value)

    The label for the choice, up to 60 characters. For example, "Green" for the value "green".

  - `description`: `string` (optional)

    The description of the choice, up to 160 characters. For example, "Croct's brand color" for the value "green".

    You can use this description to provide additional information about the option. 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).

  - `default`: `boolean` (optional) (default: false)

    Whether the choice should be preselected on the user interface.

    There can only be one default choice, otherwise the schema is considered invalid.

  - `position`: `integer` (optional)

    The order in which the choice should appear in the list, relative to other choices.

    The choices are ordered as follows:

    - Choices with lower positions appear before those with higher positions.
    - Choices with the same position have no guaranteed order between them.
    - Choices with no position appear after those with a position.
