Tag Input
Several values in one field as chips: paste a whole list, a check per value, duplicates flash, Backspace and arrows to edit.
oxyn add tag-inputrsx! {
TagInput {
label: "Labels",
value: tags(),
hint: "Enter or comma adds; paste a list",
max: Some(8),
fold: None,
on_change: move |t: Vec<String>| tags.set(t),
}
}Rendered from Rust at build time · goes live when visible
When to use
- Several short values in one field: invitees, labels, allowed domains, the files and people an agent should look at.
- The user types or pastes a list and wants each value checked and kept as a removable chip without losing what they typed.
When not to use
- Pick one or many from a searchable, grouped list: use Combobox instead.
- One input for every form: use Text Field instead.
- A small status label that carries the colour: use Badge instead.
Installation
Tag Input is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add tag-inputuse crate::oxyn::{TagInput, PRIMITIVES_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{TagInput, PRIMITIVES_CSS};
Usage
rsx! {
TagInput {
label: "Labels",
value: tags(),
hint: "Enter or comma adds; paste a list",
max: Some(8),
fold: None,
on_change: move |t: Vec<String>| tags.set(t),
}
}Examples
Labels
Short labels with a counter.
Code
rsx! {
TagInput {
label: "Labels",
value: tags(),
hint: "Enter or comma adds; paste a list",
max: Some(8),
fold: None,
on_change: move |t: Vec<String>| tags.set(t),
}
}People
Emails with initials, lowercased and checked.
Code
rsx! {
TagInput {
label: "Invite",
value: tags(),
hint: "Paste a list of emails",
max: None,
fold: None,
on_change: move |t: Vec<String>| tags.set(t),
}
}Typed context
Person, file, tool and label chips (Oxyn plus).
Code
rsx! {
TagInput {
label: "Context",
value: tags(),
hint: "Enter or comma adds; paste a list",
max: None,
typed: true,
fold: None,
on_change: move |t: Vec<String>| tags.set(t),
}
}Suggestions
Agent suggestions as you type (Oxyn plus).
Code
rsx! {
TagInput {
label: "Labels",
value: tags(),
hint: "Type “re”",
max: Some(8),
fold: None,
on_change: move |t: Vec<String>| tags.set(t),
}
}Folded
Folds past three into +N (Oxyn plus).
Code
rsx! {
TagInput {
label: "Labels",
value: tags(),
hint: "Enter or comma adds; paste a list",
max: Some(8),
fold: Some(2),
on_change: move |t: Vec<String>| tags.set(t),
}
}Error
Invalid from outside.
Code
rsx! {
TagInput {
label: "Labels",
value: tags(),
hint: "Enter or comma adds; paste a list",
max: Some(8),
fold: None,
on_change: move |t: Vec<String>| tags.set(t),
}
}API reference
TagInput
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | String | — | Label. |
value | Vec<String> | Default::default() | Starting chips. |
placeholder | String | "Add…" | Placeholder while empty (`Add more…` after the first chip). |
hint | Option<String> | Default::default() | Hint (a message takes its place while there is one). |
error | Option<String> | Default::default() | Error from the app. |
optional | bool | Default::default() | "Optional" next to the label. |
validate | String | "any" | Check: `any` · `email` · `domain` · `max:24`. |
normalize | String | "trim" | Clean: `trim` · `lower` · `slug`. |
split_on_space | bool | Default::default() | Also split on spaces. |
max | Option<usize> | Default::default() | Max chips (shows `3/10`). |
avatar | bool | Default::default() | Initials circle on every chip (people). |
typed | bool | Default::default() | Oxyn plus: icon per chip kind (person, file, tool, label). |
suggestions | Vec<String> | Default::default() | Oxyn plus: suggestions offered as you type. |
fold | Option<usize> | Default::default() | Oxyn plus: fold chips past this count into `+N`. |
name | Option<String> | Default::default() | Form field name (one hidden input per chip). |
disabled | bool | Default::default() | Disabled. |
on_change | EventHandler<Vec<String>> | — | Changed. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Enteror, | Turn what you typed into a chip (Tab does too, then moves on) |
| Space | Also adds, with split_on_space |
| ⌫ | On an empty field: first press marks the last chip, the second removes it |
| ←or→ | Walk the chips; Backspace or Delete removes the one in focus |
| Enter on a chip | Moves it back into the field to edit (Oxyn plus) |
| Esc | Clears the pick, then what you were typing |
Accessibility
- A real text input with a label; chips sit before it, each with a labelled Remove button.
- Adds, removals, duplicates and limits are announced in a polite live region.
- A message sets aria-invalid and is linked with aria-describedby.
- Chips are reached with ← from the start of the field, so Tab moves straight on.
From the spec
A real labelled input; chips are spans with a labelled "Remove {value}" button (tabindex=-1; the keyboard reaches chips with ←). Adds, removals, duplicates and limits go to a polite live region ("Added sam@acme.dev, 2 of 8"). Messages set aria-invalid and are linked with aria-describedby. Chip contrast meets 4.5:1 on surface.hover.
Motion & interaction
New chips grow in from 86 % with a short blur; removed chips leave and their neighbours close the gap. A duplicate flashes the chip it repeats. Pasting a list adds each value in turn. The counter and +N roll. Typed chips (Oxyn plus) carry a person, file, tool or label icon.
Timing
| Transition | Duration | Easing | Reduced motion |
|---|---|---|---|
| Chip in | 160 ms, scale .86 → 1, blur 3 → 0 | ease.out | 1 ms |
| Duplicate flash | 600 ms | ease.out | none |
Counter / +N roll | 200 ms | ease.out | swap |
| Message in | 180 ms rise | ease.out | swap |
Responsive behaviour
- Chips wrap; after about five lines the field scrolls inside.
- Long values end in … with the full text on hover.
- Touch: taller chips, a bigger × and 16 px input text (no iOS zoom).
Edge cases (spec)
Long values end in … at 14 rem with the full text in title. A pasted list keeps rejected parts in the field so nothing is lost. Space only splits with split_on_space. Very long lists scroll inside the field after ~5 lines. Normalisation (trim / lower / slug) happens before the duplicate check. RTL: chips flow from the right, ← / → follow visual order. Touch: 24 px × targets, 16 px input text (no iOS zoom).
Notes for AI
- Import
TagInputfromoxyn_dioxusand includePRIMITIVES_CSSplus the token stylesheet once. - A GPUI version exists:
TagInputElinoxyn_gpui. - Props to set first:
label. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.