---
type: doc
title: Swatch
description: Native Liquid swatch with readable CSS and shared data-slot parts.
---

> Native Liquid and CSS. Install from `https://ui.full.dev/r/liquid/{name}.json`; see [layout setup](/liquid/docs/installation.md). No Tailwind or consuming build.

```liquid title="liquid/examples/swatch.liquid"
<fieldset data-slot='field-set'>
  <legend data-slot='field-legend' data-variant='label'>Color</legend>
  <div style='display:flex;flex-wrap:wrap;gap:8px'>
    <a data-slot='toggle' data-variant='outline' href='#navy' aria-current='true'>
      <span data-slot='swatch' style='background-color:#1e3a5f' aria-hidden='true'></span>
      Navy
    </a>
    <a data-slot='toggle' data-variant='outline' href='#sand'>
      <span data-slot='swatch' style='background-color:#d8c7a6' aria-hidden='true'></span>
      Sand
    </a>
    <a data-slot='toggle' data-variant='outline' href='#white'>
      <span data-slot='swatch' style='background-color:#ffffff' aria-hidden='true'></span>
      White
    </a>
    <a data-slot='toggle' data-variant='outline' href='#stripe'>
      <span
        data-slot='swatch'
        style='background-image:repeating-linear-gradient(45deg,#1e3a5f 0 3px,#ffffff 3px 6px)'
        aria-hidden='true'
      ></span>
      Stripe
    </a>
  </div>
</fieldset>
```

## Installation

```bash
npx shadcn@latest add https://ui.full.dev/r/liquid/swatch.json https://ui.full.dev/r/liquid/toggle.json https://ui.full.dev/r/liquid/field.json
```

Follow the [one-time layout setup](/liquid/docs/installation/). A full `components` install already includes this item.

## Usage

After this install, render these once in the layout head before theme overrides and other modules. The full `ui` hook already includes them. The command also installs the parts used in this example.

```liquid
{% render 'ui-init' %}
{% render 'ui-swatch' %}
{% render 'ui-triggers' %}
{% render 'ui-runtime' %}
{% render 'ui-toggle' %}
{% render 'ui-input' %}
{% render 'ui-field' %}
```

The preview and its Usage tab render the same native Liquid source. Use `data-slot` for parts, `data-variant` for variants and `data-size` for sizes. Keep your store's labels, translations and Shopify data in your theme.

A swatch shows a color or pattern beside an option or filter value. Set its background from Shopify's swatch, such as `background-color: {{ value.swatch.color }}` or `background-image: url('{{ value.swatch.image | image_url: width: 48 }}')`. It is decorative, so keep the value's name in text or in the label of its toggle. Option values as links with `aria-current` or as labels around a radio input take the toggle look; see [Toggle](/liquid/components/toggle/).

## Parts

`swatch`.

[Component source](https://github.com/fulldotdev/ui/tree/main/liquid/snippets/ui-swatch.liquid) · [Theming](/liquid/docs/theming/)

## Install what this page shows

```bash
npx shadcn@latest add https://ui.full.dev/r/liquid/swatch.json https://ui.full.dev/r/liquid/toggle.json https://ui.full.dev/r/liquid/field.json
```
