Tooltip
Tooltip (툴팁)
Tooltip은 요소 위에 마우스를 올렸을 때 메시지를 보여줄 때 쓰는 컴포넌트예요.
출처: 문서
본문
tooltip을 붙인 요소에 data-tip 속성 값으로 툴팁 텍스트를 지정합니다. 위치와 색상을 고를 수 있고, tooltip-content로 텍스트 대신 커스텀 내용을 넣을 수도 있어요.
| 클래스명 | 타입 | 설명 |
|---|---|---|
tooltip |
Component | 컨테이너 요소 |
tooltip-content |
Part | 선택 사항. data-tip 텍스트 대신 툴팁 내용으로 쓸 div |
tooltip-top |
Placement | 위쪽에 표시 [기본값] |
tooltip-bottom |
Placement | 아래쪽에 표시 |
tooltip-left |
Placement | 왼쪽에 표시 |
tooltip-right |
Placement | 오른쪽에 표시 |
tooltip-start |
Placement | 시작(왼쪽)으로 정렬 |
tooltip-center |
Placement | 가운데 정렬 |
tooltip-end |
Placement | 끝(오른쪽)으로 정렬 |
tooltip-open |
Modifier | 툴팁 강제로 열기 |
tooltip-primary |
Color | primary 컬러 |
tooltip-secondary |
Color | secondary 컬러 |
tooltip-accent |
Color | accent 컬러 |
tooltip-info |
Color | info 컬러 |
tooltip-success |
Color | success 컬러 |
tooltip-warning |
Color | warning 컬러 |
tooltip-error |
Color | error 컬러 |
Tooltip
<div class="tooltip" data-tip="hello">
<button class="btn">Hover me</button>
</div>
Tooltip with tooltip-content
<div class="tooltip">
<div class="tooltip-content">
<div class="animate-bounce text-orange-400 -rotate-10 text-2xl font-black">Wow!</div>
</div>
<button class="btn">Hover me</button>
</div>
Force open (강제로 열기)
<div class="tooltip tooltip-open" data-tip="hello">
<button class="btn">Force open</button>
</div>
Top (위)
<div class="tooltip tooltip-open tooltip-top tooltip-start" data-tip="hello">
<button class="btn">Top start</button>
</div>
<div class="tooltip tooltip-open tooltip-top" data-tip="hello">
<button class="btn">Top</button>
</div>
<div class="tooltip tooltip-open tooltip-top tooltip-end" data-tip="hello">
<button class="btn">Top end</button>
</div>
Bottom (아래)
<div class="tooltip tooltip-open tooltip-bottom tooltip-start" data-tip="hello">
<button class="btn">Bottom start</button>
</div>
<div class="tooltip tooltip-open tooltip-bottom" data-tip="hello">
<button class="btn">Bottom</button>
</div>
<div class="tooltip tooltip-open tooltip-bottom tooltip-end" data-tip="hello">
<button class="btn">Bottom end</button>
</div>
Left (왼쪽)
<div class="tooltip tooltip-open tooltip-left tooltip-start" data-tip="hello">
<button class="btn">Left start</button>
</div>
<div class="tooltip tooltip-open tooltip-left" data-tip="hello">
<button class="btn">Left</button>
</div>
<div class="tooltip tooltip-open tooltip-left tooltip-end" data-tip="hello">
<button class="btn">Left end</button>
</div>
Right (오른쪽)
<div class="tooltip tooltip-open tooltip-right tooltip-start" data-tip="hello">
<button class="btn">Right start</button>
</div>
<div class="tooltip tooltip-open tooltip-right" data-tip="hello">
<button class="btn">Right</button>
</div>
<div class="tooltip tooltip-open tooltip-right tooltip-end" data-tip="hello">
<button class="btn">Right end</button>
</div>
Primary color
<div class="tooltip tooltip-open tooltip-primary" data-tip="primary">
<button class="btn btn-primary">primary</button>
</div>
Secondary color
<div class="tooltip tooltip-open tooltip-secondary" data-tip="secondary">
<button class="btn btn-secondary">secondary</button>
</div>
Accent color
<div class="tooltip tooltip-open tooltip-accent" data-tip="accent">
<button class="btn btn-accent">accent</button>
</div>
Info color
<div class="tooltip tooltip-open tooltip-info" data-tip="info">
<button class="btn btn-info">info</button>
</div>
Success color
<div class="tooltip tooltip-open tooltip-success" data-tip="success">
<button class="btn btn-success">success</button>
</div>
Warning color
<div class="tooltip tooltip-open tooltip-warning" data-tip="warning">
<button class="btn btn-warning">warning</button>
</div>
Error color
<div class="tooltip tooltip-open tooltip-error" data-tip="error">
<button class="btn btn-error">error</button>
</div>
Responsive tooltip. only show for large screen (큰 화면에서만 보이는 반응형 툴팁)
lg: 프리픽스를 붙이면 큰 화면에서만 툴팁이 동작합니다.
<div class="lg:tooltip" data-tip="hello">
<button class="btn">Hover me</button>
</div>
Responsive tooltip position (반응형 툴팁 위치)
화면 크기에 따라 툴팁 위치를 바꿀 수 있어요.
<div class="tooltip tooltip-start md:tooltip-right md:tooltip-center" data-tip="hello">
<button class="btn">Hover me</button>
</div>
더 알아보기 (Learn more)
Tooltip은 요소에 data-tip으로 짧은 설명을 덧붙일 때 가장 간단하게 쓸 수 있어요. 위치·색상 클래스를 조합해 원하는 방향으로 배치하고, 단순 텍스트 이상의 내용(아이콘, 애니메이션 등)이 필요하면 tooltip-content를 쓰세요. 반응형이 필요하면 lg:나 md: 프리픽스를 붙여 화면 크기별로 동작을 조절할 수 있습니다.