jekyll-color-copy-tag
A jekyll-color-copy-tag demo with copy buttons and paint swatches labeled with their hex values.
Open Source Plugin ∙

jekyll-color-copy-tag

A Jekyll plugin that adds a Liquid tag for clickable hex color buttons and paint swatches that copy the color to your clipboard.

jekyll-color-copy-tag is a Jekyll plugin that renders clickable hex color buttons and paint swatches. Click one and the hex value lands on your clipboard. It uses WCAG contrast ratio math to pick black or white text so the label is always readable, and it ships with its own SVG icons and a small JavaScript helper. You don’t need FontAwesome or any other icon library.

GitHub Repository · RubyGems

Demo

Copy Buttons

Jason Blue #0D2B45
Sea Glass #55793E
Peach Accent #FF7A59
Sunlight #FFC857

Paint Swatches

Jason Blue
#0D2B45
Sea Glass
#55793E
Peach Accent
#FF7A59
Sunlight
#FFC857

Swatches can be any size you want, too:

Custom 200×150 Swatch
#0D2B45

Installation

Add the gem to your Gemfile:

gem "jekyll-color-copy-tag"

Enable it in _config.yml:

plugins:
  - jekyll-color-copy-tag

That’s it. The plugin adds the JavaScript to any page that uses the tag.

Usage

Copy Buttons

Copy buttons come in three sizes:

{% color_copy '#2BB3B1' %}          {# medium (default) #}
{% color_copy '#2BB3B1', sm %}      {# small #}
{% color_copy '#2BB3B1', lg %}      {# large #}

Paint Swatches

Paint swatches show the hex value in the corner:

{% color_copy '#2BB3B1', swatch %}                {# uses config dimensions #}
{% color_copy '#2BB3B1', swatch_150x150 %}      {# override to 150×150 #}
{% color_copy '#2BB3B1', swatch_200x100 %}      {# custom width×height #}

Configuration

You can set the color that flashes after a copy and the default swatch size in _config.yml:

color_copy:
  copied_color: "#2BB3B1"
  swatch_width: 100
  swatch_height: 100
  • copied_color: the background color shown when a button or swatch is clicked (defaults to #2BB3B1)
  • swatch_width: paint swatch width in pixels (defaults to 100px)
  • swatch_height: paint swatch height in pixels (defaults to 100px)

Features

  • WCAG accessible: picks black or white text using WCAG contrast ratio math, so the label stays easy to read
  • No dependencies: includes its own SVG icons, so you don’t need FontAwesome or another icon library
  • Copy to clipboard: one click copies the hex value and shows a visual confirmation
  • Flexible sizing: small, medium, and large buttons, plus paint swatches in any size you set
  • Standards compliant: renders semantic HTML and follows accessibility best practices

Credits

Icons come from Bootstrap Icons (MIT License)