Skip to content
portalbits
Home Docs GitHub(opens in a new tab)

Guides

Get startedFoundationsMotion

Components

All components

Buttons

ButtonIconButton

Inputs

InputSelectTextareaSlider

Selection

CheckboxToggleToggleGroupSwitchRadioGroup

Identity

AvatarBadge

Overlays

DialogPopoverTooltipDropdownMenuAlertDialog

Disclosure

TabsAccordion

Cards

AppCardArticleCardFeatureCard

Content

CarouselSectionHeaderEmptyStateAlertProgressSeparatorRowListRow

Chrome

PortalShellSidebarNavMobileNavTopBarAuthFrameColorSelectorFloatingNav

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

NameTypeDefaultRequiredBindingDescription
valuestring#19e783NoBindableThe accent as a hex color. Invalid values show the default green.
openbooleanfalseNoBindableWhether the popover is open.
labelstringAccent colorNoOne-wayNames the trigger, the popover, and its heading.
theme'light' | 'dark'lightNoOne-wayTheme scope for the portaled content. Portaled content does not inherit the page scope.
onValueChange(value: string) => voidNoneNoOne-wayCalled 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.

Related

  • Popover
Previous AuthFrame Next FloatingNav

On this page

  • Preview
  • Source
  • API reference
  • Props
  • Forwarded attributes
  • Limits