A colorful Statamic Addon

July 17, 2019

Clients and content editors often want a lot of choices and make everything customizable to fit their style or the content.

But how do you provide them this choice without a risk of ruining you or your team's thoughtful design decisions?

Meet Color Swatches, a Statamic addon that allows a content editor to pick from a predefined set of colors

Color swatches
An example configuration

Using color swatches

Add the fieldtype to your fieldset, you can define multiple colors for a swatch by using a YAML array. It's also possible to set a default color by entering the label.

 1sections:
 2  main:
 3    display: Main
 4    fields:
 5      color:
 6        type: color_swatches
 7        colors:
 8          red: '#E3342F'
 9          orange: '#F6993F'
10          green: '#38C172'
11          blue-yellow:
12            - '#4299E1'
13            - '#ECC94B'
14        default: blue

After adding and configuring the fieldset, you can use the values in your template

 1{{ color.label }}
 2{{ color.value }}
 3{{ color.value.0 }} <!-- When you have more than one color -->

If you want to give it a try, you can check it out over at the Statamic Marketplace!

MENU