PHPackages                             tractorcow/silverstripe-colorpicker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tractorcow/silverstripe-colorpicker

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

tractorcow/silverstripe-colorpicker
===================================

Color picker field for Silverstripe CMS using the ColorPicker jQuery plugin

4.2.1(1y ago)18250.8k↑13.6%15[5 issues](https://github.com/tractorcow/silverstripe-colorpicker/issues)12JavaScriptCI passing

Since Jan 27Pushed 1y ago3 watchersCompare

[ Source](https://github.com/tractorcow/silverstripe-colorpicker)[ Packagist](https://packagist.org/packages/tractorcow/silverstripe-colorpicker)[ RSS](/packages/tractorcow-silverstripe-colorpicker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (8)Used By (12)

silverstripe-colorpicker
========================

[](#silverstripe-colorpicker)

The ColorPicker Module adds a color-picker input field to the SilverStripe CMS. It makes use of the ColorPicker jQuery Plugin.

Requirements
------------

[](#requirements)

SilverStripe Framework v4+, v5+, &amp; v6+

For a Version that is compatible to SilverStripe 3+, consider using the [3.0 release](https://github.com/tractorcow/silverstripe-colorpicker/releases/tag/3.0.0)For a Version that is compatible to SilverStripe 5+, consider using the [4.0 release](https://github.com/tractorcow/silverstripe-colorpicker/releases/tag/4.2.1)

Installation
------------

[](#installation)

Install using composer

```
composer require tractorcow/silverstripe-colorpicker
```

Usage
-----

[](#usage)

Here's how you define a DB field to be a color:

```
private static $db = [
    'BgColor' => 'Color'
];
```

Alternatively, you can also use the fully qualified classname. The best way to do this is to import the class at the top of your PHP file, like so:

```
use TractorCow\Colorpicker\Color;
use TractorCow\Colorpicker\Forms\ColorField;

```

In your class, you can then use:

```
private static $db = [
    'BgColor' => Color::class
];
```

That's all... scaffolding will take care of creating the appropriate form-field.

If you use `getCMSFields` to create your fields yourself, you might want to do something like this:

```
public function getCMSFields()
{
    $fields = parent::getCMSFields();

    $fields->addFieldToTab(
    	'Root.Main',
    	ColorField::create('BgColor', 'Background color')
    );

    return $fields;
}
```

### Tips for using the Color fieldtype in templates

[](#tips-for-using-the-color-fieldtype-in-templates)

The `TractorCow\Colorpicker\Color` fieldtype provides some helper methods that can be useful in templating. Let's consider the above scenario where you have a Field named 'BgColor'. The most common use-case is something like this:

```

...
```

But there's more. You could also use CSS3 `rgba` color definitions with alpha. Example:

```

...
```

This will color your background with an alpha value of `0.5` (browsers that don't support rgba, such as IE-8 will fall back to the first background-color definition, that's why it's still in there).

Here's a complete list of the `Color` methods available in templates:

- `Red` returns the red color component
- `Green` returns the green color component
- `Blue` returns the blue color component
- `CSSColor` returns the color as `rgba`. The alpha value can be specified with the (optional) argument.
- `Luminance` the luminance of the color as a floating-point value ranging from 0-1
- `Blend` blends the color with a second background color (defaults to #FFFFFF) with the given opacity. `$BGColor.Blend(0.5, '#000000')` will give the color 50% opacity and put it on top of a black background.
- `AlteredColorHSV` modifies the current color by the given HSV values. These values are offsets, so you could do something like this: `$BgColor.AlteredColorHSV(0.5, 0, 0)` which will return the color with the opposite hue. All parameters are percentage based and range from `0 - 1`. So doing: `$BgColor.AlteredColorHSV(0, 0, -0.2)` will result in a color with 20% less brightness (absolute, not relative).
- `ColorCMS` returns HTML code with a visual representation and the HEX code of the color for usage in CMS. Can be used in `$summary_fields` of a DataObject: `$summary_fields = [ 'Color.ColorCMS' => 'Color' ];` so that GridFields will always render the visible color instead of only the HEX code.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance40

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~613 days

Recently: every ~647 days

Total

7

Last Release

449d ago

Major Versions

3.0.x-dev → 4.0.02018-01-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/f6a363b2d85dc3e82e73cc9e3a57fc15132920b166c5938ad63a54029b9f94b9?d=identicon)[tractorcow](/maintainers/tractorcow)

![](https://www.gravatar.com/avatar/04057079b9a8a168a9e8c40cf7bac17f05047255c48b71b63fc610db06f096cb?d=identicon)[robbieaverill](/maintainers/robbieaverill)

---

Top Contributors

[![tractorcow](https://avatars.githubusercontent.com/u/936064?v=4)](https://github.com/tractorcow "tractorcow (10 commits)")[![bummzack](https://avatars.githubusercontent.com/u/1006185?v=4)](https://github.com/bummzack "bummzack (6 commits)")[![sebastiand](https://avatars.githubusercontent.com/u/974056?v=4)](https://github.com/sebastiand "sebastiand (2 commits)")[![UndefinedOffset](https://avatars.githubusercontent.com/u/1391558?v=4)](https://github.com/UndefinedOffset "UndefinedOffset (2 commits)")[![schrattenholz](https://avatars.githubusercontent.com/u/46528228?v=4)](https://github.com/schrattenholz "schrattenholz (1 commits)")[![satrun77](https://avatars.githubusercontent.com/u/166450?v=4)](https://github.com/satrun77 "satrun77 (1 commits)")[![robbieaverill](https://avatars.githubusercontent.com/u/5170590?v=4)](https://github.com/robbieaverill "robbieaverill (1 commits)")[![RVXD](https://avatars.githubusercontent.com/u/1586761?v=4)](https://github.com/RVXD "RVXD (1 commits)")[![alexhayes](https://avatars.githubusercontent.com/u/142916?v=4)](https://github.com/alexhayes "alexhayes (1 commits)")

---

Tags

silverstripecolorcolorpickercolour

### Embed Badge

![Health badge](/badges/tractorcow-silverstripe-colorpicker/health.svg)

```
[![Health](https://phpackages.com/badges/tractorcow-silverstripe-colorpicker/health.svg)](https://phpackages.com/packages/tractorcow-silverstripe-colorpicker)
```

###  Alternatives

[tecnickcom/tc-lib-color

PHP library to manipulate various color representations

247.2M9](/packages/tecnickcom-tc-lib-color)[presseddigital/colorit

A slick color picker fieldtype plugin for the Craft CMS 3 control panel.

2132.1k](/packages/presseddigital-colorit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
