|
Need a developer but don't need a full-time employee? I now offer subscription full stack engineering. Ship faster and build better systems. Pause or cancel any time. I've been putting the finishing touches on the color palette for Kelp, my UI library for people who love HTML. Today, I wanted to share how it works, and give you a sneak peak of the color palette generator I'm building to make theming Kelp without build tools fast and easy. Let's dig in! Building a palette from base colorsWhat I want users to be able to do is pick a single color for each hue in the rainbow and automatically generate a range of brightness/saturation combos for that hue. This should give you a set of options from very dark to very light that you can use to create background/text options for various components, without having to hard-code each individual color in the palette. For example, imagine entering
And with that palette, a dozen named CSS variables that you can use in your code… This is the backbone of theming in Kelp. The base colorsBecause LGBTQ+ people have been so integral to the creation of the web, and because it's Pride Month, and because the Progress Flag colors are just so fucking gorgeous, it only seemed fitting that the Progress Pride Flag colors are the base color set for Kelp. With one exception: yellow. The hue of yellow used in the Pride Flag has green tones in it that really come out strong in the middle brightness ranges, so I shifted the hue a bit until I found one that still looked good but still looked like yellow throughout the whole palette. The Progress Flag also doesn't have indigo in it, so I blended the purple and blue together to find an indigo hue that's harmonious with the other colors. Here are the official base colors for the palette:
Adjusting base colors to create a paletteThere are a lot of color space algorithms for adjusting colors. For a while, HSL—Hue Saturation Lightness—was one of the more popular ones for creating palettes. But it has a tendency to create palettes that feel a bit less natural. LCH—Lightness Chroma Hue—uses a color graph that more accurately reflects how the human eye perceives color.
A lot of building the Kelp palette was finding the right mix of lightness and chroma at each stop in the palette. Once you go below around After a bunch of trial-and-error, here's where I ended up:
The one exception is grayscale colors, whose chroma is already Building a color palette generatorTo pull this all together, I used the awesome You pass in your desired base color for each color in the palette as a hex code. The I can then loop over each of the lightness/chroma combos, passing the hue with the new L and C values back into The generator then spits out a bunch of copy/paste CSS variables for each hue in all of its shades. Adjusting the vibrancyFrom testing, one "issue" with this setup is that most hues within in a color spit out pretty similar looking palettes because the chroma is being set to a fixed number. To provide for more variation, I added a vibrancy field with a range of When generating the shades, I multiply the chroma by this percentage. Try it!You can try the generator for yourself on CodePen. Pop in some different colors, adjust the vibrancy in different directions, and see how your color palettes come out using your favorite brand colors. If you see anything weird or having any feedback, get in touch and let me know! This is still in development, so any feedback you have is invaluable. Semantic ColorsHaving named color variables is cool and all, but working on projects, you generally don't want to have to swap out Kelp includes a second section that maps different named colors to semantic values: These are defined once, in a single location. The rest of the CSS files reference these semantic variables rather than color names. If you need to update a theme, you can swap out half a dozen semantic names in one spot, and everything else automatically updates… without a build step! We'll look more at how that works this week. Until then, you can learn more at KelpUI.com. Learn more about subscription full stack engineering. Ship faster and build better systems. Cheers, Want to share this with others or read it later? View it in a browser. |

0 Komentar untuk "[Go Make Things] How to create an accessible color palette"