Viewing Sass Themes Colors with Color Swatches

Published Jun 01, 2019

Tags:

Color Swatch

maximumred
indianred
orangered
 <div class="swatch_group">
   ...
   <div class="swatch color-${COLOR_NAME}">
     <span class="swatch__name">${COLOR_NAME}</span>
     <span class="swatch__color" data-color="${COLOR_VALUE}"></span>
     <span class="swatch__bgcolor" data-name="${COLOR_NAME}"></span>
   </div>
   ....
 </div>

One of the problems that comes up with frontend development using libraries and functions to create your stylesheets is that you dont always have a visual reference to what is available in your current project.

If youre using bootstrap you can go to their site and check out the styleguide, but in a lot of cases (almost always) the styles have been added to, modified, or combined with other libraries.

So how do you see all the colors the project your’e working on has if there is no realtime reference guide. This is what motivated me to create the color swatch component for my style library. The color swatch is basically a single block element that uses the ‘currentColor’ property and inheritance to show you several variations of text and color using a color utility class. The data-[property] fields are used to display the text for ::before and ::after elements, which lets me set the text once and display it in both the light and dark variation.

I also have a handful of sass mixins that will dynamicaly write in comment blocks to the color sections of the color definition sections with html to show all the colors in a theme.

For an example I created a swatch set for the Crayola color set colors

standard

red
maroon
scarlet
brickred
englishvermilion
madderlake
maximumred
indianred
orangered
sunsetorange
bittersweet
darkvenetianred
venetianred
lightvenetianred
vividtangerine
middlered
burntorange
redorange
orange
macaroniandcheese
middleyellowred
mangotango
yelloworange
maximumyellowred
bananamania
maize
orangeyellow
goldenrod
dandelion
yellow
greenyellow
middleyellow
olivegreen
springgreen
maximumyellow
canary
lemonyellow
maximumgreenyellow
middlegreenyellow
inchworm
lightchromegreen
yellowgreen
maximumgreen
asparagus
grannysmithapple
fern
middlegreen
green
mediumchromegreen
forestgreen
seagreen
shamrock
mountainmeadow
junglegreen
caribbeangreen
tropicalrainforest
middlebluegreen
pinegreen
maximumbluegreen
robinseggblue
tealblue
lightblue
aquamarine
turquoiseblue
outerspace
skyblue
middleblue
bluegreen
pacificblue
cerulean
maximumblue
bluei
ceruleanblue
cornflower
greenblue
midnightblue
navyblue
denim
blueiii
cadetblue
periwinkle
blueii
wildblueyonder
indigo
manatee
cobaltblue
celestialblue
bluebell
maximumbluepurple
violetblue
blueviolet
ultramarineblue
middlebluepurple
purpleheart
royalpurple
violetii
mediumviolet
wisteria
lavenderi
vividviolet
maximumpurple
purplemountainsmajesty
fuchsia
pinkflamingo
violeti
brilliantrose
orchid
plum
mediumrose
thistle
mulberry
redviolet
middlepurple
maximumredpurple
jazzberryjam
eggplant
magenta
cerise
wildstrawberry
lavenderii
cottoncandy
carnationpink
violetred
razzmatazz
pigpink
carmine
blush
ticklemepink
mauvelous
salmon
middleredpurple
mahogany
melon
pinksherbert
burntsienna
brown
sepia
fuzzywuzzy
beaver
tumbleweed
rawsienna
vandykebrown
tan
desertsand
peach
burntumber
apricot
almond
rawumber
shadow
rawsiennai
timberwolf
goldi
goldii
silver
copper
antiquebrass
black
charcoalgray
gray
bluegray

fluorescent

radicalred
wildwatermelon
outrageousorange
atomictangerine
neoncarrot
sunglow
laserlemon
unmellowyellow
electriclime
screamingreen
magicmint
blizzardblue
shockingpink
razzledazzlerose
hotmagenta
purplepizzazz

bright

sizzlingred
redsalsa
tartorange
orangesoda
brightyellow
yellowsunshine
slimygreen
greenlizard
denimblue
bluejeans
plumppurple
purpleplum
sweetbrown
brownsugar
eerieblack
blackshadows
fieryrose
sizzlingsunrise
heatwave
lemonglacier
springfrost
absolutezero
wintersky
frostbite