Skip to content

Color Area Examples

The examples below assume that you have imported the component and set up the theme.

Basic

Let the user pick two channels of a color in one area. value holds the saturation and brightness, separated by a space, and the valuechange event updates the readout.

The controls pick the x and y channels in each color-space.

The thumb and the paint follow the border radius of the area.

--active
Sets the first channel in channels .
Sets the second channel in channels . Sets the first channel in channels . Sets the second channel in channels . Sets the first channel in channels . Sets the second channel in channels .
Layout
4%
Sets --sv-area-slider-bdr-rad .
Markers
A <datalist> of <option> values in the markers-x and markers-y slots.
State
<div class="color-area-basic">
<sv-color-area
style="--sv-area-slider-marker-clr: transparent"
aria-label="Color"
value="76 96"
></sv-color-area>
<output></output>
</div>
<script type="application/x-typescript" module>
const colorArea = document.querySelector<ColorArea>(".color-area-basic sv-color-area")!;
const valueOutput = document.querySelector<HTMLOutputElement>(".color-area-basic output")!;
updateValueOutput();
colorArea.addEventListener("valuechange", updateValueOutput);
function updateValueOutput() {
valueOutput.value = `value="${colorArea.value}"`;
}
</script>
<style>
.color-area-basic {
display: grid;
gap: 0.75em;
justify-items: center;
output {
font-variant-numeric: tabular-nums;
}
}
</style>