Tag
태그 구성 요소는 시각적 레이블, 범주 또는 키워드를 나타냅니다. 다양한 변형, 모양, 대화형 닫기 동작, 사용자 지정 아이콘 및 동적 슬롯 콘텐츠를 지원합니다.
언제 사용하나요
- 차원이나 속성별로 태그를 지정하는 데 사용할 수 있습니다.
- 분류할 때.
Tag
태그는 기본(default) 및 윤곽선(outline) 변형으로 제공됩니다. 기본적으로 태그는 제거 가능합니다.
Default Tag Outline Tag
astro
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Default Tag" removable={false} />
<Tag variant="outline" label="Outline Tag" removable={false} /> Tag
태그는 기본, 성공, 경고, 위험, 정보와 같은 컨텍스트를 전달하기 위해 다양한 색상 의도를 지원합니다.
Primary Success Warning Danger Info
astro
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Primary" intent="primary" removable={false} />
<Tag label="Success" intent="success" removable={false} />
<Tag label="Warning" intent="warning" removable={false} />
<Tag label="Danger" intent="danger" removable={false} />
<Tag label="Info" intent="info" removable={false} /> Tag
shape 속성(알약 또는 사각형)을 사용하여 태그의 테두리 반경을 제어합니다.
Pill Shape Square Shape
astro
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Pill Shape" shape="pill" />
<Tag label="Square Shape" shape="square" /> Tag
removable={true}(기본값)를 설정하여 닫기 버튼을 표시합니다. 기본적으로 클릭하면 DOM 노드가 완전히 제거됩니다. onRemove 속성을 통해 이를 재정의할 수 있습니다.
Closable Tag Alert on Close
astro
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Closable Tag" />
<Tag label="Alert on Close" onRemove="alert('Tag closed!'); this.parentElement.remove();" /> Tag
iconLeft 및 iconRight 속성을 사용하여 왼쪽이나 오른쪽에 아이콘을 추가합니다. label 속성을 사용하는 대신 동적 콘텐츠를 슬롯으로 전달할 수도 있습니다.
Search Settings
Custom Slot Tag
astro
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Search" iconLeft="Search" removable={false} />
<Tag label="Settings" iconRight="Settings" removable={false} />
<Tag removable={false}>
<div class="flex items-center gap-1.5 text-blue-600 dark:text-blue-400">
<span class="w-2 h-2 rounded-full bg-blue-500"></span>
Custom Slot Tag
</div>
</Tag> Tag
태그를 비활성화로 표시하여 상호 작용을 방지할 수 있습니다.
Disabled Tag
astro
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Disabled Tag" disabled /> API 참조
| 속성 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| variant | 시각적 스타일 변형 | 'default' | 'outline' | 'default' |
| intent | 컨텍스트에 대한 색상 의도 | 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default' |
| shape | 테두리 반경 모양 | 'pill' | 'square' | 'pill' |
| disabled | 상호 작용을 비활성화하고 불투명도를 줄입니다. | boolean | false |
| removable | 닫기 버튼을 표시합니다 | boolean | true |
| label | 텍스트 내용(슬롯을 사용하지 않는 경우) | string | '-' |
| iconLeft | 왼쪽에 표시할 아이콘 이름 | IconName | '-' |
| iconRight | 오른쪽에 표시할 아이콘 이름 | IconName | '-' |
| onRemove | 닫기를 클릭할 때 실행할 JavaScript 문자열 | string | '-' |