ColorSelector
Five presets, a gradient, and an exact hex value.
#19E783
Source
<script lang="ts">
import 'portal-bits/styles.css';
import 'portal-bits/tokens.css';
import type { Snippet } from 'svelte';
let { children }: { children: Snippet } = $props();
</script>
{@render children()}
<script lang="ts">
import ColorSelectorExample from './ColorSelectorExample.svelte';
</script>
<ColorSelectorExample />
<script lang="ts">
import { ColorSelector } from 'portal-bits';
let accent = $state('#19e783');
</script>
<div class="row">
<ColorSelector bind:value={accent} />
<span>{accent.toUpperCase()}</span>
</div>
<style>
.row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 14px;
}
</style>
API reference
These tables list the props and snippets that ColorSelector declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.
Props
| Name | Type | Default | Required | Binding | Description |
|---|---|---|---|---|---|
value | string | #19e783 | No | Bindable | The accent as a hex color. Invalid values show the default green. |
open | boolean | false | No | Bindable | Whether the popover is open. |
label | string | Accent color | No | One-way | Names the trigger, the popover, and its heading. |
theme | 'light' | 'dark' | light | No | One-way | Theme scope for the portaled content. Portaled content does not inherit the page scope. |
onValueChange | (value: string) => void | None | No | One-way | Called with a normalized six-digit hex string after each user change. |
Forwarded attributes
None. ColorSelector forwards no attributes.
No data attributes are documented as stable.
Limits
- The component sets no CSS. Apply `--portal-accent` and persist the value yourself.
- Five fixed presets plus a custom gradient. Alpha is not supported.
- The presets and gradient dimensions are an adaptation.
- Selecting a color keeps the popover open.