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
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 stateAdd it
npx qatjs add chipsChipsInput
As a custom element: <ui-chips-input>.
| Prop | Type | Attribute |
|---|---|---|
label | QatNode | property only |
values | string[] | property only |
placeholder | string | yes |
help | QatNode | property only |
error | QatNode | property only |
max | number | yes |
validate | (v: string) => true | string | property only |
disabled | boolean | yes |
removeLabel | (v: string) => string | property only |
| Event | Detail |
|---|---|
on:update:values | CustomEvent<string[]> |
Keys
| Key | Does |
|---|---|
| Enter, comma | add |
| Backspace | in the empty input, remove the last |