Tags Input
Display submitted tags one by one.
Basic Example
<script>
import { Tags, TagsDelete, TagsInput, TagsItem } from 'lithesome';
let tags = $state([]);
</script>
<Tags bind:value={tags}>
<div class="inline-flex flex-wrap gap-1">
{#each tags as tag}
<TagsItem value={tag}>
<span>{tag}</span>
<TagsDelete value={tag}>X</TagsDelete>
</TagsItem>
{/each}
</div>
<TagsInput />
</Tags>
API Reference
<Tags />
| Property | Type | Description |
|---|---|---|
value | string[] | The current value. |
disabled | boolean | Disables the entire group, stops all events from firing. |
max | number | The maximum allowed of tags. |
whitelist | string[] | Allow only these strings to be added to the `value` prop. |
blacklist | string[] | Don't allow these string to be addeed to the `value` prop. |
ref | E | The reference to the underlying element. |
children | Snippet<[ S extends Record<string, any> ? S : never ]> | The default snippet to render. |
custom | Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]> | Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it. |
| State | Type | Description |
|---|---|---|
activeTag | string | null | The value if the selected tag via keyboard navigation. |
invalid | boolean | True if: - Input value is less than 1. - Tag already exists. - Tag isn't in the whitelist. - Tag isn't allowed by the blacklist. |
<TagsInput />
| Property | Type | Description |
|---|---|---|
ref | E | The reference to the underlying element. |
| State | Type | Description |
|---|---|---|
invalid | boolean | True if: - Input value length is less than 1. - Tag already exists. - Tag isn't in the whitelist. - Tag isn't allowed by the blacklist. |
<TagsItem />
| Property | Type | Description |
|---|---|---|
value | string | The value of the tag. |
ref | E | The reference to the underlying element. |
children | Snippet<[ S extends Record<string, any> ? S : never ]> | The default snippet to render. |
custom | Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]> | Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it. |
| State | Type | Description |
|---|---|---|
active | boolean | True if selected via keyboard navigation. |
<TagsDelete />
| Property | Type | Description |
|---|---|---|
value | string | The value of the item to remove. |
ref | E | The reference to the underlying element. |
children | Snippet<[ S extends Record<string, any> ? S : never ]> | The default snippet to render. |
custom | Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]> | Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it. |