SwipeUI

Tag input

Text becomes trimmed unique chips with named removal actions and optional count limits.

npx @swipeui/cli add tag-input
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Adding labels, skills, interests or keywords to an item.
  • Entering several email addresses or names as separate chips.
  • Pasting a comma-separated list and turning it into tags.
  • Limiting how many tags can be added.

When not to use it

  • Choosing from a fixed set. Use Chip group or Multi-select.
  • A single value. Use Text field.
  • Long free text. Use Textarea.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add tag-input
  • Adds components/swipeui/ui/tag-input.tsx and 13 shared helpers.
  • Installs react-native-reanimated, react-native-svg, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/post.tsx
import { TagInput } from '@/components/swipeui/ui/tag-input';

<TagInput label="Tags" defaultValue={['Mobile']} />;

Examples

Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.

API reference

TagInputProps

PropTypeDefaultDescription
label?string—

Visible label, or inherit an enclosing Field.

helper?string—

Instructions under the field; an error or success message replaces it.

error?string—

Validation message: a destructive ring, an alert glyph, one shake and an error haptic.

success?string—

Confirmation under the field, such as "Username available", in the success colour.

status?FieldStatus'idle'

validating shows a spinner and reports busy; valid draws a check on. An error implies invalid.

required?booleanfalse

Required; "Required" is spoken, and requiredIndicator marks the label. The app owns validation.

requiredIndicator?FieldRequiredIndicator'asterisk'

How a required label is marked: a muted asterisk, the word, or nothing.

optionalIndicator?booleanfalse

Show a muted "Optional" after the label.

disabled?booleanfalse

Disable editing and accessory actions.

disabledStyle?FieldDisabledStyle'muted'

muted lightens the fill and text without opacity; dim lowers the field to 50%.

appearance?FieldAppearance'filled'

The surface: filled (a soft fill), outline (a hairline), underline or ghost (no fill until focused).

size?FieldSize'md'

Height: sm 36pt, md 44pt, lg 52pt.

shape?FieldShape'preset'

preset follows your preset's control radius; pill is a capsule.

labelPlacement?FieldLabelPlacement'above'

above, inset (small, inside at the top), floating (rests centred like a hint and rises on focus or once there's a value) or hidden (spoken only).

focusRing?FieldFocusRing'halo'

The focus indicator: a primary ring with a soft halo, the ring alone, or none.

messageMorph?FieldMessageMorph'fade'

How a changed message arrives: rises in, letter by letter, or at once.

reserveMessageSpace?booleanfalse

Keep one line of room under the field so forms don't move as messages appear.

displayValue?React.ReactNode—

Decorative rendering for an unfocused value; the native text remains the accessible/editable source.

prefix?React.ReactNode—

Decorative prefix or an accessible accessory, drawn first.

suffix?React.ReactNode—

Accessible trailing accessory, drawn last.

leadingIcon?ButtonIcon—

A leading icon: a node, or a function given the state colour and size. It turns primary while focused.

trailingIcon?ButtonIcon—

A trailing icon: a node, or a function given the state colour and size.

clearable?booleanfalse

1.x switch: true means clearButton="always".

clearButton?TextFieldClearButton'never' (or 'always' with `clearable`)

When a "Clear text" button shows.

undoClear?booleantrue

After clearing, the button becomes "Undo clear" for a moment. Phones have no ⌘Z.

undoClearWindow?number4000

How long undo stays, in milliseconds.

counter?TextFieldCounterfalse

A rolling character counter under the field, using maxLength; amber near the limit, red at it.

tintCaret?booleantrue

Caret and selection in the primary colour.

iconTint?"focus" | "none"'focus'

The leading icon turns primary while focused (focus) or stays muted (none).

shakeOnError?booleantrue

Shake once for each new error. Reduce Motion keeps it still.

messages?Partial<FieldMessages>FIELD_MESSAGES (English)

Built-in strings, for translation.

nextRef?React.RefObject<_TextInputInstance | null>—

Ref focused when Return is pressed; otherwise a single-line field dismisses.

haptics?boolean | FieldHapticstrue (clear, error and limit)

All feedback, or each part: { clear, error, valid, limit, focus }.

motion?MotionOverridethe app feel

Ring, label and message motion.

className?string—

Classes on the outer field.

controlClassName?string—

Classes on the field surface.

inputClassName?string—

Classes on the editable text.

style?StyleProp<ViewStyle>—

Outer field style.

inputStyle?____TextStyleProp_Internal—

Native editable text style.

value?readonly string[]—

Controlled unique tag values.

defaultValue?readonly string[][]

Initial tag values.

onValueChange?((value: readonly string[]) => void)—

Reports accepted insertions/removals.

animateTags?booleantrue

Animate pill insertion and removal; Reduce Motion uses a fade.

removeLabel?((tag: string) => string)tag => `Remove ${tag}`

Translate each pill removal action.

maxTags?numberInfinity

Maximum number of tags.

Native view/input props not listed here pass through where the exported TypeScript type allows them.

Composition and behavior

  • A wrapping row of capsule pills inside the filled Text field.
  • value and onValueChange hold the tags.
  • maxTags limits the count.

Tag input settings

Enter or comma commits a unique trimmed tag into a capsule pill inside the same field. The label and named removal icon stay centered together. Insertions and removals animate; Reduce Motion uses a fade.

PropDoesDefault
maxTagsMaximum committed tagsInfinity
animateTagsAnimate pill insertion and removaltrue
removeLabelTranslate pill removal namesRemove tag

The compact pill fits the first 44pt field row. Its plain cross has a 44pt hit area. On an empty editor, Backspace selects the last pill; a second Backspace removes it. Typing cancels the selection.

Behavior and gestures

  • Type a tag and press Return, or type a comma, to add it as a chip.
  • Pasting "red, green, blue" adds three tags at once.
  • Spaces are trimmed and duplicates are ignored.
  • Tap a pill's plain cross to remove it. In an empty field, the first Backspace selects the final pill and the second removes it.
  • Once maxTags is reached, extra tags aren't added.

Accessibility

  • Each chip has a remove button named "Remove <tag>".
  • The input is labelled like Text field.
  • Chips wrap onto new lines, so large text never hides them.

Motion

  • Uses the press motion role, so it follows your app's feel. Pass motion to tune this one instance.
  • Remove buttons use the shared press scale.

Performance

  • Tags are a simple string array; adding is a set merge.

Notes for AI

  • Use value with onValueChange to store tags; set maxTags to cap them.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items