# Tag list

- Entry point: `@koobiq/components/tags`
- NgModule: `KbqTagsModule`
- API: https://koobiq.io/api/tags.md
- Page: https://koobiq.io/en/components/tag-list/overview

Tag List displays a collection of tags and supports keyboard navigation, multiple selection, and removal.

[**Example: Tag list overview** (`tag-list-overview`)](https://koobiq.io/examples/tag-list-overview.md)

## Tag removal

Tag removal order:

- If there are selected tags, all of them will be removed.
- If there are no selected tags, the focused tag will be removed.

Tags can be removed in several ways:

- Click on the remove icon (`kbqTagRemove` directive) inside the tag.
- Press `Delete` or `Backspace` key.
- Programmatic removal through the component [API](https://koobiq.io/api/tags.md).

The removal option is configured using the `removable` attribute (enabled by default). A disabled tag does not show its remove icon.

[**Example: Tag list removable** (`tag-list-removable`)](https://koobiq.io/examples/tag-list-removable.md)

## Tag selection

Tags can be selected in several ways:

- Click on a tag while holding `Ctrl`.
- Click on a tag while holding `Shift` to change the selection range from the anchor tag to the clicked tag.
- Press `Shift` + `←` / `→` to expand or shrink the range.
- Press `Ctrl+A` key combination.
- `Space` when the tag is focused.
- Programmatic selection through the component [API](https://koobiq.io/api/tags.md).

Pointer and keyboard interactions change the same range relative to its initial tag. When the range shrinks, tags outside it are deselected. Disabled tags remain unchanged.

The selection option is configured using the `selectable` attribute (enabled by default).

## Editing

To enable editing mode, you need to set the `editable` property for `kbq-tag-list` or individual `kbq-tag`.

Entering the mode:

- By double-clicking on the tag.
- By pressing the `Enter` or `F2` key (when focused on the tag).

Saving changes:

- By pressing the `Enter` key.
- By clicking the confirmation button (`kbqTagEditSubmit` directive).

Canceling changes:

- By pressing the `Escape` key.
- When losing focus.

[**Example: Tag list editable** (`tag-list-editable`)](https://koobiq.io/examples/tag-list-editable.md)

## Drag and drop

To enable tag reordering, you need to set the `draggable` property for `kbq-tag-list`.

[**Example: Tag list draggable** (`tag-list-draggable`)](https://koobiq.io/examples/tag-list-draggable.md)

## Keyboard navigation

### Focus on tag

| Key                | Action                           |
| ------------------ | -------------------------------- |
| ← / →              | Move focus to previous/next tag. |
| Shift + ← / →      | Change the range and move focus. |
| Space              | Select/deselect tag.             |
| Delete / Backspace | Remove tag.                      |
| F2 / Enter         | Start editing.                   |
| Ctrl + A           | Select all tags.                 |
| Home / End         | Move focus to first/last tag.    |

### Tag editing mode

| Key   | Action          |
| ----- | --------------- |
| Enter | Save changes.   |
| Esc   | Cancel changes. |
