An <sp-color-area>
allows users to visually select two properties of a color simultaneously. It's commonly used together with a color slider or color wheel.
yarn add @spectrum-web-components/color-area
Import the side effectful registration of <sp-color-area>
via:
import '@spectrum-web-components/color-area/sp-color-area.js';
When looking to leverage the ColorArea
base class as a type and/or for extension purposes, do so via:
import { ColorArea } from '@spectrum-web-components/color-area';
When using the color elements, use el.color
to access the color
property, which should manage itself in the colour format supplied. For example, If you supply a color in rgb()
format, el.color
should return the color in rgb()
format, as well. In ColorArea, colours are formatted as hex values.
The current color formats supported are as follows:
- Hex3, Hex4, Hex6, Hex8
- HSV, HSVA
- HSL, HSLA
- RGB, RGBA
- Strings (eg "red", "blue")
<sp-color-area></sp-color-area>
An <sp-color-area>
in a disabled state shows that an input exists, but is not available in that circumstance. This can be used to maintain layout continuity and communicate that the area may become available later.
<sp-color-area disabled></sp-color-area>
An <sp-color-area>
’s height and width can be customized appropriately for its context.
<sp-color-area
style="
width: 72px;
height: 72px"
></sp-color-area>
An <sp-color-area>
renders accessible labels for each axis: "saturation" and "luminosity".
Specify label-x
and label-y
attributes to override these defaults.
<sp-color-area
label-x="Color intensity"
label-y="Color brightness"
></sp-color-area>