Actions JS behaviour

Label creator

Notion-style chips-in-a-field: type a new name, pick its colour, press Enter — a tiny pixel loader spins and the chip pops in.

Real scenarios

The component as it is used in a product — not a specimen grid.

Labelling an issue

Type a name, pick a colour, press Enter: a tiny loader spins on the create button, the chip pops in with its dot, and the server hears it through nx-label-created.

Colour

0 labels live on the server

A plain form with its own palette

Without Livewire the list posts as JSON under the name you give — here with a three-swatch palette to match a brand.

  • Launch
  • Client work
Colour

Small print

  • Enter creates, Escape clears what you typed, Backspace removes the last chip.
  • Every chip is removable with a real button and a per-chip aria-label.

Important props

Important props
Prop Type Default What it does
labels array [] The initial labels: each with name and color.
colors array null The colour swatches (value · label · color); defaults to the seven chart colours.
placeholder / label / colorLabel string 'Add a label…' / 'Labels' / 'Colour' The field’s visible words; all bilingual overridable.
createText string 'Create “:name”' The create button’s text; :name marks the typed name.
name string null Without wire:model: with name, the list posts as JSON through a hidden input.

Snippet

<x-nx::label-creator wire:model.live="state.labels" placeholder="برچسب تازه…"
    create-text="ساخت «:name»" color-label="رنگ"
    x-on:nx-label-created="$wire.ping('برچسب ساخته شد: ' + $event.detail.name)" />