Swatches are used to make variant selections easier and more intuitive for customers when they are selecting an option with color. Swatches appear throughout your theme in various places and can be used with custom images or hex code colors.
In order to display swatches on a product page or within a product card we can use metafield connected variant options. This might sound complicated but it's super easy to setup and works great out of the box.
From here you'll be able to change the hexcode or image of each swatch by clicking into it.
Your collection page filtering can be customized from the Shopify Search and Discovery app. Using this app you can add new filters and customize how they appear on your theme.
Shopify has recently made a number of improvements to metafields and how they work with swatches. This is great news for us because now swatches are much easier to manage and update.
Create metaobject for your swatch
Create metafield to link to metaobject
We now have to assign values so data is populated for our new metafields.
Assign values to each product
From here you can click into each product and make sure the new metafield is updated to correspond to the relevant options.
Connect to filter
Once all your data is place the only thing left is to connect this to your filters.
Caveats of metafield filtering
If you use metafield swatch filtering you'll have to ensure you update your metafields for all products that you want to appear on this filter - this will NOT happen automatically even if category metafields and variant options are displaying swatches.
You can add filters using color product options. This is a easy way to add filters but will require swatch files to be uploaded in a specific format. Swatches will only appear using this approach when the product option matches "color" - or a translation of color.
Add filter using Search and discovery
Upload missing swatch files
You may notice that not all of your color filters are appearing with swatches. If this is the case you may have to upload custom swatch files.
Swatches will only appear automatically if the color name matches a default CSS color.
Start by connecting your source repository and choosing the pages you want to publish.
You can then browse your documentation and ask questions about the content your team has shared.