Vue Ripple 디렉티브
Ripple 디렉티브는 호스트 요소에 물결(ripple) 효과를 추가해요. 버튼을 눌렀을 때 퍼지는 파문 애니메이션을 몇 줄의 설정으로 넣을 수 있어요.
출처: 문서
본문
Vue Ripple Component
Ripple directive adds ripple effect to the host element.
Accessibility
Screen Reader Ripple 요소는 aria-hidden 속성이 true로 설정되어 있어서 스크린 리더가 무시해요. Keyboard Support 이 컴포넌트에는 인터랙티브 요소가 없어요.
Configuration
시작하려면 Ripple을 전역으로 활성화해야 해요. 자세한 내용은 Configuration API를 참고하세요.
mounted() { this.$primevue.config.ripple = true; }
Composition API Example
import { usePrimeVue } from 'primevue/config'; const PrimeVue = usePrimeVue(); PrimeVue.config.ripple = true;
Custom
애니메이션의 기본 스타일은 흰색 음영을 추가해요. p-ink 요소의 색을 바꾸는 CSS로 이 부분은 간단하게 커스터마이징할 수 있어요.
<div v-ripple class="box" style="border: 1px solid rgba(75, 175, 80, 0.3); --p-ripple-background: rgba(75, 175, 80, 0.3)">Green</div>
<div v-ripple class="box" style="border: 1px solid rgba(255, 193, 6, 0.3); --p-ripple-background: rgba(255, 193, 6, 0.3)">Orange</div>
<div v-ripple class="box" style="border: 1px solid rgba(156, 39, 176, 0.3); --p-ripple-background: rgba(156, 39, 176, 0.3)">Purple</div>
Composition API Example
<template>
<div class="flex justify-center items-center gap-2">
<div v-ripple class="box" style="border: 1px solid rgba(75, 175, 80, 0.3); --p-ripple-background: rgba(75, 175, 80, 0.3)">Green</div>
<div v-ripple class="box" style="border: 1px solid rgba(255, 193, 6, 0.3); --p-ripple-background: rgba(255, 193, 6, 0.3)">Orange</div>
<div v-ripple class="box" style="border: 1px solid rgba(156, 39, 176, 0.3); --p-ripple-background: rgba(156, 39, 176, 0.3)">Purple</div>
</div>
</template>
<style scoped>
.box {
padding: 2rem;
border-radius: 10px;
width: 110px;
text-align: center;
}
</style>
Default
대상에 p-ripple 클래스를 추가하고 디렉티브를 v- 접두사와 함께 붙이면 Ripple이 활성화돼요.
<div v-ripple class="ripple-box">Default</div>
Composition API Example
<template>
<div class="card flex flex-col items-center gap-4">
<div v-ripple class="ripple-box">Default</div>
</div>
</template>
<script setup>
<\/script>
<style scoped>
.ripple-box {
display: flex;
user-select: none;
justify-content: center;
align-items: center;
padding: 3rem;
font-weight: bold;
background: var(--p-content-background);
border: 1px solid var(--p-content-border-color);
border-radius: var(--p-content-border-radius);
}
<\/style>
Ripple
Pass Through Options
| Name | Type | Description |
|---|---|---|
| root | RippleDirectivePassThroughOptionType | Used to pass attributes to the root's DOM element. |
| hooks | any | Used to manage all lifecycle hooks. |
Theming
CSS Classes
| Class | Description |
|---|---|
| p-ink | Class name of the root element |
Design Tokens
| Token | CSS Variable | Description |
|---|---|---|
| ripple.background | --p-ripple-background | Background of root |