Skip to main content

Tag

Tags for marking and selection.

Basic usage​

Basic usage
Default tagPrimary tagSuccess tagRounded tagOutlined tagInk washChinese styleComponent library
import { useState } from 'react'
import { LhTag } from '@lh-ui/react'

export default function Demo() {
const [tags, setTags] = useState(['Ink wash', 'Chinese style', 'Component library'])

const handleClose = (tag: string) => {
setTags((prev) => prev.filter((item) => item !== tag))
}

return (
<>
<LhTag>Default tag</LhTag>
<LhTag type="primary">Primary tag</LhTag>
<LhTag type="success">Success tag</LhTag>
<LhTag type="warning" round>Rounded tag</LhTag>
<LhTag type="danger" hit>Outlined tag</LhTag>
{tags.map((tag) => (
<LhTag key={tag} closable onClose={() => handleClose(tag)}>
{tag}
</LhTag>
))}
</>
)
}

Tag Props​

PropDescriptionTypeOptionsDefault
typeType'text' | 'primary' | 'success' | 'warning' | 'danger' | 'info'—'text'
sizeSize'large' | 'middle' | 'small'—From ConfigProvider
closableClosableboolean—false
disabledDisabled (no click or close)boolean—false
roundRounded cornersboolean—false
hitOutlined styleboolean—false
sxLayout shorthandSxProps——

Tag events​

EventDescriptionCallback signatureVue equivalent
onClickFired on click (when onClick is provided and not disabled, the component upgrades to role="button")(event: MouseEvent) => void@click
onCloseClose button clicked(event: MouseEvent) => void@close
Keyboard interaction

A clickable Tag renders as role="button" and responds to Enter / Space. See Accessibility.

Unmounts on close (React enhancement)

After the close button is clicked, the Tag unmounts from the DOM immediately, then fires onClose. lh-ui-plus's @close only fires an event and lets the outside remove the node with v-if; React has no directives, and forcing external state control just for unmounting a display-only tag is too heavy, so the closed state is built in. If you need full control over visibility, wrap it in a conditional render.

Styles​

import '@lh-ui/react/style/tag'