qat

Chips input

ChipsInput. It is copied into your app’s ui/ by qatjs add chips: the code is yours to edit.

Example

leyla@example.az

To leyla@example.az

Example.qx14 lines, 1 reactive nameOpen in the playground
import ChipsInput from './ui/chips/chips.qx'

export default function Example() {
  let recipients = state(['leyla@example.az'])
  return (
    <ChipsInput
      label="Recipients"
      placeholder="Add a recipient"
      validate={(v) => /^[^@\s]+@[^@\s]+$/.test(v) || 'Not an email address'}
      bind:values={recipients}
    />
    <p>To {recipients.join(', ') || 'nobody'}</p>
  )
}
recipients state

Add it

shell1 line
npx qatjs add chips

ChipsInput

As a custom element: <ui-chips-input>.

ChipsInput: props
PropTypeAttribute
labelQatNodeproperty only
valuesstring[]property only
placeholderstringyes
helpQatNodeproperty only
errorQatNodeproperty only
maxnumberyes
validate(v: string) => true | stringproperty only
disabledbooleanyes
removeLabel(v: string) => stringproperty only
ChipsInput: events
EventDetail
on:update:valuesCustomEvent<string[]>

Keys

KeyDoes
Enter, commaadd
Backspacein the empty input, remove the last