Chip (칩)
레이블, 상태, 카테고리를 표시하는 작은 정보 배지 컴포넌트예요. 짧은 정보를 한눈에 전달할 때 유용해요.
출처: HeroUI Chip
본문
사용법 (Usage)
import { Chip } from '@heroui/react';
{"demo": "chip-basic"}
구조 (Anatomy)
일반 텍스트 자식은 자동으로
<Chip.Label>로 감싸져요.
<Chip>
Label text
</Chip>
예제 (Examples)
변형 (Variants)
{"demo": "chip-variants"}
상태 (Statuses)
{"demo": "chip-statuses"}
아이콘과 함께 (With Icons)
{"demo": "chip-with-icon"}
커스터마이징 (Customization)
Tailwind CSS
{"demo": "chip-custom-styles"}
Global CSS
Chip 컴포넌트의 클래스를 커스터마이징하려면 @layer components 지시어를 사용할 수 있어요.
자세히 알아보기.
@layer components {
.chip {
@apply rounded-full text-xs;
}
.chip__label {
@apply font-medium;
}
.chip--accent {
@apply border-accent/20;
}
.chip--accent .chip__label {
@apply text-accent;
}
}
스타일링 참조 (Styling Reference)
HeroUI는 BEM 방법론을 따라 컴포넌트 변형과 상태를 재사용하고 커스터마이징하기 쉽게 만들어요.
CSS 클래스 (CSS Classes)
Chip 컴포넌트는 다음 CSS 클래스를 사용해요 (소스 스타일 보기):
기본 클래스 (Base Classes) [!toc]
.chip- 칩 기본 컨테이너 스타일.chip__label- 레이블 텍스트 슬롯 스타일
색상 클래스 (Color Classes) [!toc]
.chip--accent- 포인트 색상 변형.chip--danger- 위험 색상 변형.chip--default- 기본 색상 변형.chip--success- 성공 색상 변형.chip--warning- 경고 색상 변형
변형 클래스 (Variant Classes) [!toc]
.chip--primary- 채워진 배경의 기본 변형.chip--secondary- 테두리가 있는 보조 변형.chip--tertiary- 투명 배경의 3차 변형.chip--soft- 더 밝은 배경의 소프트 변형
크기 클래스 (Size Classes) [!toc]
.chip--sm- 작은 크기.chip--md- 중간 크기 (기본).chip--lg- 큰 크기
복합 변형 클래스 (Compound Variant Classes) [!toc]
Chip은 변형과 색상 클래스를 함께 조합할 수 있어요 (예: .chip--secondary.chip--accent). 다음 조합에는 기본 스타일이 정의되어 있어요:
기본 변형 (Primary Variants):
.chip--primary.chip--accent- 채워진 배경의 기본 강조 조합.chip--primary.chip--success- 채워진 배경의 기본 성공 조합.chip--primary.chip--warning- 채워진 배경의 기본 경고 조합.chip--primary.chip--danger- 채워진 배경의 기본 위험 조합
소프트 변형 (Soft Variants):
.chip--accent.chip--soft- 더 밝은 배경의 소프트 강조 조합.chip--success.chip--soft- 더 밝은 배경의 소프트 성공 조합.chip--warning.chip--soft- 더 밝은 배경의 소프트 경고 조합.chip--danger.chip--soft- 더 밝은 배경의 소프트 위험 조합
참고: CSS의 @layer components 지시어를 사용해 어떤 변형-색상 조합에도 커스텀 스타일을 적용할 수 있어요 (예: .chip--secondary.chip--accent, .chip--tertiary.chip--success).
API 참조 (API Reference)
Chip
| Prop | Type | Default | Description |
|---|---|---|---|
children |
React.ReactNode |
- | Content to display inside the chip |
className |
string |
- | Additional CSS classes for the root element |
color |
"default" | "accent" | "success" | "warning" | "danger" |
"default" |
Color variant of the chip |
variant |
"primary" | "secondary" | "tertiary" | "soft" |
"secondary" |
Visual style variant |
size |
"sm" | "md" | "lg" |
"md" |
Size of the chip |
Chip.Label
| Prop | Type | Default | Description |
|---|---|---|---|
children |
React.ReactNode |
- | Label text content |
className |
string |
- | Additional CSS classes for the label slot |