Skip to content

Tags Input

Input field for entering multiple tags or values.

React Vue Angular

Press Enter to add tags, Backspace to remove

## Cài đặt
bash
npx @galaxy-stack/nebula-cli add tags-input
bash
npx @galaxy-stack/nebula-cli add tags-input
bash
npx @galaxy-stack/nebula-cli add tags-input

Usage

tsx
import { TagsInput } from '@/components/tags-input'
import { useState } from 'react'

export default function TagsInputDemo() {
  const [tags, setTags] = useState<string[]>(['react', 'vue'])

  return (
    <TagsInput
      value={tags}
      onChange={setTags}
      placeholder="Add tag..."
    />
  )
}
vue
<script setup lang="ts">
import { ref } from 'vue'
import { TagsInput } from '@/components/tags-input'

const tags = ref(['react', 'vue'])
</script>

<template>
  <TagsInput
    v-model="tags"
    placeholder="Add tag..."
  />
</template>
typescript
import { Component } from '@angular/core'
import { TagsInputComponent } from '@/components/tags-input'

@Component({
  selector: 'app-tags-input-demo',
  standalone: true,
  imports: [TagsInputComponent],
  template: `
    <ui-tags-input
      [value]="tags"
      (valueChange)="tags = $event"
      placeholder="Add tag..."
    />
  `
})
export class TagsInputDemo {
  tags = ['react', 'vue']
}

API Reference

Props

PropTypeDefaultMô tảFrameworks
valuestring[][]Giá trị tags hiện tạiAll
onChange(tags: string[]) => void-Gọi khi danh sách tags thay đổiAll
onTagAdd(tag: string) => void-Gọi khi thêm tagAll
onTagRemove(tag: string) => void-Gọi khi xóa tagAll
placeholderstring'Add tag...'Văn bản giữ chỗ cho inputAll
classNamestring''CSS class cho container tagsAll
disabledbooleanfalseVô hiệu hóa việc thêm/xóa tagsAll

Features

  • Add tags by pressing Enter
  • Remove last tag with Backspace
  • Click X button to remove individual tags
  • Duplicate prevention
  • Focus ring styling

Accessibility

  • Proper keyboard navigation
  • Screen reader support for tag removal
  • Focus management

Tác giả

Bùi Trọng Hiếu (kevinbui)

Giấy phép

MIT © 2025 Bùi Trọng Hiếu (kevinbui)

Phát hành theo Giấy phép MIT.