Color
The color family wraps Reka UI’s color primitives and draws every part in the page. It looks the same in every browser and every flavor, which <input type="color"> does not.
Values are hex strings or Reka Color objects ({ space: 'hsl', h, s, l, alpha }). v-model returns whatever the primitive produces. When several parts share one value, type the ref with the component’s own modelValue prop, as the examples do. The example colors come from the nocturne palette.
NwColorPicker
Section titled “NwColorPicker”NwColorPicker is a complete picker behind one button. The button opens a Reka Popover with a saturation and brightness area, hue and opacity sliders, a hex field and a row of presets. The button shows a swatch of the current color.
Without presets, the picker offers the twelve accents of the active flavor (indigo to steel), read from @nyxwire/palette, and the row follows the flavor scoped by the nearest NwProvider. The popover content carries that provider’s data-flavor and data-accent, so a scoped island keeps its flavor even though the popover is portalled to <body>.
<script setup lang="ts">import { ref } from 'vue'import { NwColorPicker, NwProvider } from '@nyxwire/vue'
const signal = ref('#848fff')</script>
<template> <NwProvider> <div class="flex flex-wrap items-center gap-4"> <NwColorPicker v-model="signal" label="Signal color" /> <output class="font-mono text-sm text-fg-muted">{{ signal }}</output> </div> </NwProvider></template>NwColorPicker├─ trigger: NwColorSwatch + label (default slot, receives { value })└─ popover content ├─ title + close button ├─ NwColorArea (hsb: saturation × brightness) ├─ NwColorSlider channel="hue" ├─ NwColorSlider channel="alpha" ├─ NwColorField (hex) └─ NwColorSwatchPicker of presets (the flavor accents unless `presets` is set)| Prop | Type | Default | Effect |
|---|---|---|---|
modelValue |
string | Color |
none | Current color; v-model emits a string in format |
defaultValue |
string | Color |
pure red | Uncontrolled starting color; without it the picker starts at hsl 0 100 50 |
format |
ColorFormat |
'hex' |
Format of the emitted string, such as 'hex' or 'hsl' |
label |
string |
'Choose color' |
Trigger text, accessible name and popover title |
presets |
readonly { value; label? }[] |
flavor accents | Swatches under the field; [] hides the row |
disabled |
boolean |
false |
Disables the trigger and every control |
open |
boolean |
none | Controlled open state, v-model:open |
defaultOpen |
boolean |
false |
Uncontrolled initial open state |
closeLabel |
string |
'Close color picker' |
Accessible name of the close button |
class |
HTMLAttributes['class'] |
none | Merged onto the trigger |
Emits update:modelValue (a string) and update:open (a boolean). Other attributes go to the trigger button. NwColorPreset is exported as the type of one preset.
Keyboard and accessibility. The trigger is a button named by label. Opening the picker moves focus into the popover, which keeps a 16px collision padding from the viewport edge. Escape or the close button closes it and returns focus to the trigger. The area, sliders, field and presets work from the keyboard as described in the sections below.
NwColorArea
Section titled “NwColorArea”NwColorArea is a two-dimensional picker over two channels of one color space. It wraps Reka ColorAreaRoot, ColorAreaArea and ColorAreaThumb. The default slot holds the thumb and renders NwColorAreaThumb when it is empty.
<script setup lang="ts">import { ref } from 'vue'import { NwColorArea, NwColorSwatch, NwProvider, type NwColorAreaProps } from '@nyxwire/vue'
const beacon = ref<NwColorAreaProps['modelValue']>('#d071ff')</script>
<template> <NwProvider> <div class="grid w-full max-w-sm gap-3"> <NwColorArea v-model="beacon" color-space="hsb" x-channel="saturation" y-channel="brightness" aria-label="Beacon saturation and brightness" /> <div class="flex items-center gap-3 text-sm text-fg-muted"> <NwColorSwatch :color="beacon" label="Beacon color" /> <output class="font-mono">{{ beacon }}</output> </div> </div> </NwProvider></template>NwColorArea└─ NwColorAreaThumb (default slot content)| Prop | Type | Default | Effect |
|---|---|---|---|
modelValue |
string | Color |
none | Controlled color, v-model |
defaultValue |
string | Color |
'#ff0000' |
Uncontrolled starting color (Reka) |
colorSpace |
ColorSpace |
'hsl' |
Color space the channels belong to (Reka) |
xChannel |
ColorChannel |
'hue' |
Channel on the horizontal axis (Reka) |
yChannel |
ColorChannel |
'saturation' |
Channel on the vertical axis (Reka) |
disabled |
boolean |
false |
Blocks interaction and dims the area |
xName, yName |
string |
none | Input names for form submission (Reka) |
class |
HTMLAttributes['class'] |
none | Merged onto the root |
The other Reka ColorAreaRoot props and emits pass through. The area is 12rem tall and fills its container’s width.
Keyboard. The thumb is the focusable control, and the arrow keys move it along both axes. Give the area an aria-label that names both channels.
NwColorSlider
Section titled “NwColorSlider”NwColorSlider shows one channel of a color on a gradient track and wraps Reka ColorSliderRoot and ColorSliderThumb. The track paints the channel gradient over a checkerboard, so you can see the alpha channel.
<script setup lang="ts">import { ref } from 'vue'import { NwColorSlider, NwColorSwatch, NwProvider, type NwColorSliderProps } from '@nyxwire/vue'
const trace = ref<NwColorSliderProps['modelValue']>('#5eddfecc')const channels = [ { channel: 'hue', label: 'Hue' }, { channel: 'saturation', label: 'Saturation' }, { channel: 'lightness', label: 'Lightness' }, { channel: 'alpha', label: 'Opacity' },] as const</script>
<template> <NwProvider> <div class="grid w-full max-w-sm gap-2"> <div class="flex items-center gap-3 text-sm text-fg-muted"> <NwColorSwatch :color="trace" size="lg" label="Trace color" /> <output class="font-mono">{{ trace }}</output> </div> <div v-for="item in channels" :key="item.channel" class="grid gap-1 text-xs text-fg-muted"> <span>{{ item.label }}</span> <NwColorSlider v-model="trace" :channel="item.channel" :label="`Trace ${item.label}`" /> </div> </div> </NwProvider></template>| Prop | Type | Default | Effect |
|---|---|---|---|
channel |
ColorChannel |
required | 'hue', 'saturation', 'lightness', 'alpha', … |
modelValue |
string | Color |
none | Controlled color, v-model |
defaultValue |
string | Color |
'#000000' |
Uncontrolled starting color (Reka) |
colorSpace |
ColorSpace |
'hsl' |
Color space of channel (Reka) |
orientation |
'horizontal' | 'vertical' |
'horizontal' |
Vertical sliders are 10rem tall; the gradient follows |
inverted |
boolean |
false |
Reverses the axis (Reka) |
dir |
'ltr' | 'rtl' |
provider dir |
Reading direction; the gradient flips in right-to-left |
step |
number |
channel step | Keyboard step (Reka) |
label |
string |
none | aria-label of the thumb, the focusable control |
disabled |
boolean |
false |
Blocks interaction and dims the slider |
class |
HTMLAttributes['class'] |
none | Merged onto the root |
The other Reka ColorSliderRoot props and emits pass through. Reka 2.11 always draws a left-to-right gradient. NwColorSliderTrack keeps Reka’s colors and checkerboard but points the gradient along the slider’s actual axis, so vertical, inverted and right-to-left sliders show the right colors under the thumb. It is exported for custom slider layouts.
Keyboard. Arrow keys change the channel by step, and Home and End jump to the ends. The thumb has the slider role and reports its orientation. Set label so it has a name.
NwColorField
Section titled “NwColorField”NwColorField is a text input for a color, wrapping Reka ColorFieldRoot and ColorFieldInput. Without channel it edits the hex value. With channel it edits that one number. The text uses the mono font with tabular figures, and the field shows a wire edge when focused.
<script setup lang="ts">import { ref } from 'vue'import { NwColorField, NwColorSwatch, NwProvider, type NwColorFieldProps } from '@nyxwire/vue'
const status = ref<NwColorFieldProps['modelValue']>('#4bf677')</script>
<template> <NwProvider> <div class="grid w-full max-w-xs gap-4"> <div class="grid gap-2 text-sm text-fg-muted"> <span>Status light</span> <div class="flex items-center gap-3"> <NwColorSwatch :color="status" label="Status light" /> <NwColorField v-model="status" label="Status light hex" /> </div> </div> <div class="grid gap-2 text-sm text-fg-muted"> <span>Status light hue</span> <NwColorField v-model="status" channel="hue" size="sm" label="Status light hue" /> </div> <output class="font-mono text-sm text-fg-muted">{{ status }}</output> </div> </NwProvider></template>| Prop | Type | Default | Effect |
|---|---|---|---|
modelValue |
string | Color |
none | Controlled color, v-model |
channel |
ColorChannel |
none | Edit one channel instead of the hex value (Reka) |
colorSpace |
ColorSpace |
'hsl' |
Space of channel (Reka) |
size |
'sm' | 'md' | 'lg' |
'md' |
Input height 2rem, 2.5rem or 3rem |
label |
string |
'Color value' |
aria-label of the input |
invalid |
boolean |
false |
Sets aria-invalid and the danger edge |
disabled |
boolean |
false |
Disables the input |
readonly |
boolean |
false |
Read-only input (Reka) |
placeholder |
string |
none | Placeholder when empty (Reka) |
class |
HTMLAttributes['class'] |
none | Merged onto the input |
The other Reka ColorFieldRoot props and emits pass through. Other attributes, such as id or aria-describedby, go to the input, so an outer <label for> can target it.
Keyboard and accessibility. The value is parsed when the input commits, on Enter or blur. Invalid text is rejected and the previous color stays; channel values are clamped to their range. ArrowUp and ArrowDown step the value. Point an error message at the input with aria-describedby and set invalid.
NwColorSwatch
Section titled “NwColorSwatch”NwColorSwatch previews one color over a checkerboard and cannot be interacted with. It wraps Reka ColorSwatch, which gives it role="img" and a name derived from the color unless you pass label.
<script setup lang="ts">import { NwColorSwatch, NwProvider } from '@nyxwire/vue'
const sizes = ['sm', 'md', 'lg'] as const</script>
<template> <NwProvider> <div class="flex flex-wrap items-center gap-4"> <NwColorSwatch v-for="size in sizes" :key="size" color="#f8e445" :size="size" :label="`Volt yellow, ${size}`" /> <NwColorSwatch color="#f8e445" size="lg" shape="square" label="Volt yellow, square" /> <NwColorSwatch color="#5eddfe80" size="lg" label="Ice at half opacity" /> </div> </NwProvider></template>| Prop | Type | Default | Effect |
|---|---|---|---|
color |
string | Color |
none | Color to show (Reka) |
label |
string |
color name | Accessible name (Reka) |
size |
'sm' | 'md' | 'lg' |
'md' |
1.5rem, 2rem or 2.75rem square |
shape |
'rounded' | 'square' |
'rounded' |
Corner radius |
class |
HTMLAttributes['class'] |
none | Merged onto the root |
The default slot renders over the color, for a badge or an icon.
NwColorSwatchPicker
Section titled “NwColorSwatchPicker”NwColorSwatchPicker is a grid of preset swatches with one selected. It wraps Reka ColorSwatchPickerRoot (a listbox) and ColorSwatchPickerItem. Each item is a 2.75rem cut-corner tile. Its chamfered edge lights up in the primary color and glows when the item is selected, and a check badge appears in the corner. The grid fits as many 2.75rem columns as its width allows.
<script setup lang="ts">import { computed, ref } from 'vue'import { flavors } from '@nyxwire/palette'import { NwColorSwatchPicker, NwColorSwatchPickerItem, NwProvider } from '@nyxwire/vue'
const { colors } = flavors.nocturneconst presets = (['indigo', 'synth', 'ice', 'matrix', 'volt', 'alarm'] as const).map((name) => ({ value: colors[name].hex, label: colors[name].label,}))const team = ref(presets[2]?.value)const teamLabel = computed(() => presets.find((preset) => preset.value === team.value)?.label)</script>
<template> <NwProvider> <div class="grid w-full max-w-xs gap-3"> <NwColorSwatchPicker v-model="team" aria-label="Team color"> <NwColorSwatchPickerItem v-for="preset in presets" :key="preset.value" :value="preset.value" :label="preset.label" /> </NwColorSwatchPicker> <output class="font-mono text-sm text-fg-muted">{{ teamLabel }} {{ team }}</output> </div> </NwProvider></template>NwColorSwatchPicker└─ NwColorSwatchPickerItem (one per preset)| Part | Prop | Type | Default | Effect |
|---|---|---|---|---|
NwColorSwatchPicker |
modelValue |
string | string[] |
none | Selected color, v-model |
defaultValue |
string | string[] |
none | Uncontrolled selection | |
disabled |
boolean |
false |
Disables every item | |
class |
HTMLAttributes['class'] |
none | Merged onto the grid | |
NwColorSwatchPickerItem |
value |
string |
required | The color, a hex string |
label |
string |
none | Accessible name of the option and its swatch | |
shape |
'rounded' | 'square' |
'rounded' |
Swatch shape |
The picker accepts Reka’s other listbox props (multiple, orientation, …), except by. An item’s default slot receives { selected } and replaces the swatch and the check.
Keyboard and accessibility. Give the picker an aria-label. Arrow keys move between swatches and select them, updating v-model. The grid shows a focus ring when it has focus, and the highlighted item takes the bright line color.