# Settings

Theme settings, section and block settings, defaults, and what happens to the merchant's values on updates.

Settings are the fields the merchant fills in the theme editor. You declare them in a schema; the platform builds the form, validates input and hands resolved values to your templates.

## Theme settings

Theme-wide settings - colours, fonts, logo, page width - live in `config/settings_schema.json`, a list of groups:

```json
[
  {
    "name": "theme_info",
    "theme_name": "Example",
    "theme_version": "1.4.0",
    "theme_author": "Example Studio",
    "theme_documentation_url": "https://example.com/docs"
  },
  {
    "name": "t:settings.colors.name",
    "settings": [
      { "type": "color", "id": "color_background", "default": "#fafafa", "label": "t:settings.colors.background" },
      { "type": "color", "id": "color_accent", "default": "#0f0f0f", "label": "t:settings.colors.accent" }
    ]
  },
  {
    "name": "t:settings.layout.name",
    "settings": [
      { "type": "range", "id": "page_width", "min": 1000, "max": 1800, "step": 20, "unit": "px", "default": 1440, "label": "t:settings.layout.page_width" },
      { "type": "range", "id": "radius", "min": 0, "max": 24, "step": 1, "unit": "px", "default": 0, "label": "t:settings.layout.radius" }
    ]
  }
]
```

Templates read them from the global `settings`: `{{ settings.page_width }}`. A long schema can be split into `config/settings/*.json` - see [File structure](file-structure.md#settings-split-across-files).

## Section and block settings

Sections and blocks declare settings in the `settings` array of their `{% schema %}`, with the same types. Read them as `section.settings.<id>` and `block.settings.<id>`.

## A setting

| Key | Required | Description |
| --- | --- | --- |
| `type` | yes | One of the [setting types](../reference/setting-types.md). |
| `id` | yes | Unique within its schema - `snake_case`. It is the key in templates and in stored values: **never rename it** in a released theme, or every store loses that value. |
| `label` | yes | Field label, usually a `t:` key. |
| `default` | | The starting value. Without it a setting is empty - `null`, or `false` for a checkbox. |
| `info` | | Help text under the field. |
| `placeholder` | | Placeholder for text fields. |
| `options` | for `select` | A list of `{ value, label }`. |
| `min`, `max`, `step`, `unit` | for `range` | The slider bounds; values outside them are clamped. |
| `content` | for `header`, `paragraph` | The text shown in the editor. |
| `limit` | for `store_reviews` | How many reviews. |

## Resolved values

The platform does the lookup work before your template runs. A `product` setting gives a [product](../reference/objects/product.md) object, a `category_list` a list of categories, a `link_list` a [menu](../reference/objects/menu.md), an `image_picker` a [file](../reference/objects/file.md) you pass straight to `|image_url`. An offer that was deleted later simply drops out. Write templates for the empty case:

```twig
{% if section.settings.product %}
  {{ render('product-card', { product: section.settings.product }) }}
{% endif %}
```

`richtext` and `html` values are sanitised when the merchant saves them **and** when they are read, so `{{ section.settings.text|raw }}` is safe even for values that came from your package.

## Validation

Input is checked against the schema when the merchant saves: numbers are clamped to the range, a `select` value must be one of the options, a colour must be `#rrggbb`, a URL must be a store path or an `http(s)`, `mailto:` or `tel:` address. Settings that are not in the schema are dropped. You never need to defend a template against a value the schema does not allow.

## Starting values

`config/settings_data.json` holds the values a store starts with:

```json
{
  "current": {
    "color_background": "#fafafa",
    "page_width": 1440
  }
}
```

## Updates

When a store updates to a new version of your theme:

- every value the merchant set is kept,
- new settings arrive with their defaults,
- settings you removed are parked, not deleted, so rolling back brings them back.

That is why `id`s are forever. To change what a setting means, add a new one.
