Tag
Tag for categorizing or markup.
Examples
Basic
Basic Tag usage. Set the closable to allow it to be closed. It also supports an on:close event.
Colors
The Tag has a set of predefined colors. The color can also be set to a custom hex color string.
Presets:
magenta red volcano orange gold lime green cyan blue geekblue purple
Custom:
#f50 #2db7f5 #87d068 #108ee9
Icon
Tag components can contain an Icon. This is done by setting the icon property or placing an Icon component within the Tag.
Status
There are five different preset colors that can be used to communicate status. The following can be set using the color property. success, processing, error, default, and warning.
Without icon
success processing error warning defaultWith icon
success processing error warning waiting stopAdd & Remove Dynamically
Controlled Visibility
The visibility can be controlled using the visible prop.
Checkable
Use the checked prop to make the Tag work like a checkbox. Click a tag to toggle its checked state.
API
Attributes
| Property | Description | Type | Default |
|---|---|---|---|
| closable | Whether the Tag can be closed | Boolean | false |
| visible | Whether the Tag is closed or not | Boolean | false |
| color | Color of the tag. See examples above in the `Color` and `Status` sections for details | String | |
| class | Class name or class object (e.x. class={{'abc':true}}) for the Tag. | String|Object | |
| icon | Sets the icon of the tag | SvelteComponent | |
| checked | Checked status of Tag. If this prop is included the tag will be `checkable` and the background will be transparent by default | Boolean | |
| disableTransition | Disable the fade and scale effect when the tag appears/disappears | Boolean | false |
Events
| Name | Description |
|---|---|
| click | Specify a function that will be called when a user clicks the tag. |
| close | Specify a function that will be called when the user closes the tag by clicking the close icon. To prevent the tag from closing, a `event.detail.preventClose()` function is exposed. |