import '../icon-button/icon-button'; import { classMap } from 'lit/directives/class-map.js'; import { customElement, property } from 'lit/decorators.js'; import { html } from 'lit'; import { LocalizeController } from '../../utilities/localize'; import ShoelaceElement from '../../internal/shoelace-element'; import styles from './tag.styles'; import type { CSSResultGroup } from 'lit'; /** * @summary Tags are used as labels to organize things or to indicate a selection. * @documentation https://shoelace.style/components/tag * @status stable * @since 2.0 * * @dependency sl-icon-button * * @slot - The tag's content. * * @event sl-remove - Emitted when the remove button is activated. * * @csspart base - The component's base wrapper. * @csspart content - The tag's content. * @csspart remove-button - The tag's remove button, an ``. * @csspart remove-button__base - The remove button's exported `base` part. */ @customElement('sl-tag') export default class SlTag extends ShoelaceElement { static styles: CSSResultGroup = styles; private readonly localize = new LocalizeController(this); /** The tag's theme variant. */ @property({ reflect: true }) variant: 'primary' | 'success' | 'neutral' | 'warning' | 'danger' | 'text' = 'neutral'; /** The tag's size. */ @property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium'; /** Draws a pill-style tag with rounded edges. */ @property({ type: Boolean, reflect: true }) pill = false; /** Makes the tag removable and shows a remove button. */ @property({ type: Boolean }) removable = false; private handleRemoveClick() { this.emit('sl-remove'); } render() { return html` ${this.removable ? html` ` : ''} `; } } declare global { interface HTMLElementTagNameMap { 'sl-tag': SlTag; } }