Part of the Color ecosystem · 10 projects
This module provides a highly customizable color picker field for Drupal, allowing users to select colors using hexadecimal notation. It supports adding multiple color fields to content and entities with various themes and predefined formatters for displaying the selected colors.
Color Pickr adds a color field to Drupal with a fast, accessible color picker and seven ways to display the chosen color. The picker is built into the module: no external library, CDN or Composer package is needed.
Use it for brand colors, category colors, background and text colors, status labels, palettes, or anything else editors should choose visually instead of typing a color code.
Features
- Built-in color picker with a color area, hue and opacity sliders, and three styles: Classic, Monolith and Nano.
- Eyedropper that picks the exact color of any point on the page (text, images, gradients), like the browser's DevTools color picker.
- Swatches for quick selection: site-wide, per field, or none. A field can be limited to its swatch colors only.
- Recently used colors, remembered in the browser.
- Any color format as input: HEX, RGB(A), HSL(A), HSVA, CMYK and CSS color names.
- Choice of saved format: HEX, HEX with alpha, RGBA or HSLA, with or without transparency.
- Popup or always visible picker, with an optional hidden text field for a cleaner form.
- Accessible: full keyboard support, ARIA labels and screen reader announcements. Works with mouse and touch.
- Secure: colors are validated on save and sanitized on output, so stored values can not inject CSS.
- Single or multiple values, and works in AJAX forms such as Add another item.
- Compatible with Drupal 10, 11 and 12.
Display formatters
- Default: the color code as text, in the format of your choice.
- Badge: the color code on a pill filled with the color, with readable text.
- Square, Circle, Rectangle, Hexagon: a shape filled with the color, with a size setting and an optional color code.
- Line: a full-width line, with a thickness setting.
Translucent colors are shown over a checkerboard, and every formatter can be themed by copying its Twig template into your theme.
Post-installation
- Add a field of type Color Pickr to any content type or entity (Structure » Content types » Manage fields).
- On Manage form display, choose the picker style, saved format, transparency, swatches and eyedropper.
- On Manage display, choose one of the seven formatters.
- Optionally, set the site-wide swatches at Configuration » User interface » Color Pickr.
Upgrading from 1.1.x
Version 2.0.0 keeps your fields, saved colors and settings. Run drush updb after updating. If you customized the old Pickr library with your own JavaScript or CSS, review those changes, because the Pickr library has been replaced. See the 2.0.0 release notes for details.
Requirements
Drupal core 10, 11 or 12. No other modules or libraries.
Similar projects
Color Field offers several widgets based on HTML5 and third-party libraries. Color Pickr focuses on a single built-in picker with an eyedropper, site-wide swatches and shape formatters, with no external dependencies.
Support
Report bugs and request features in the issue queue. Patches and merge requests are welcome.
Ask your assistant about Color Pickr
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- field Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
More in the Color ecosystem
Most installed first