PressableFeedback (누름 피드백)
PressableFeedback은 누름 상호작용에 대한 시각적 피드백을 자동 스케일 애니메이션과 함께 제공하는 컨테이너 컴포넌트예요. iOS 스타일의 하이라이트와 Android 스타일의 리플을 비롯해 다양한 피드백 레이어를 조합할 수 있어요. 누름 상태와 컨테이너 크기를 관리해 자식 복합 파트가 context를 통해 이를 활용하게 해요.
출처: 문서
본문
Import
import { PressableFeedback } from 'heroui-native';
Anatomy
<PressableFeedback>
<PressableFeedback.Highlight />
<PressableFeedback.Ripple />
<PressableFeedback.Scale>...</PressableFeedback.Scale>
</PressableFeedback>
- PressableFeedback: 내장 스케일 애니메이션이 있는 Pressable 컨테이너예요. 누름 상태와 컨테이너 크기를 관리하고 이를 자식 복합 파트에 context로 제공해요.
PressableFeedback.Scale을 대신 사용할 때는animation={false}로 내장 스케일을 비활성화해요. - PressableFeedback.Scale: 특정 자식 요소에 스케일을 적용하는 스케일 애니메이션 래퍼예요. 어느 요소가 스케일될지 제어하거나 스케일 래퍼에
className/style을 적용해야 할 때 루트의 내장 스케일 대신 사용해요. - PressableFeedback.Highlight: iOS 스타일 누름 피드백용 하이라이트 오버레이예요. 누름 시 페이드 인되는 절대 위치 레이어를 렌더링해요.
- PressableFeedback.Ripple: Android 스타일 누름 피드백용 리플 오버레이예요. 터치 지점에서 확장되는 방사형 그라데이션 원을 렌더링해요.
Usage
Basic
PressableFeedback은 누름 다운 스케일 피드백을 기본 제공해요. 대부분의 경우 이렇게 사용하는 것을 권장해요.
<PressableFeedback>...</PressableFeedback>
With Highlight
내장 스케일과 함께 iOS 스타일 피드백 효과를 위해 하이라이트 오버레이를 추가해요.
<PressableFeedback>
<PressableFeedback.Highlight />
...
</PressableFeedback>
With Ripple
내장 스케일과 함께 Android 스타일 피드백 효과를 위해 리플 오버레이를 추가해요.
<PressableFeedback>
<PressableFeedback.Ripple />
...
</PressableFeedback>
Custom Scale Animation
animation.scale prop으로 내장 스케일 애니메이션을 커스텀해요. value, timingConfig, ignoreScaleCoefficient를 받아요.
<PressableFeedback
animation={{
scale: {
value: 0.9,
timingConfig: { duration: 150 },
ignoreScaleCoefficient: true,
},
}}
>
...
</PressableFeedback>
Custom Highlight Animation
하이라이트 오버레이의 투명도와 배경색을 설정해요.
<PressableFeedback>
<PressableFeedback.Highlight
animation={{
backgroundColor: { value: '#3b82f6' },
opacity: { value: [0, 0.2] },
}}
/>
...
</PressableFeedback>
Custom Ripple Animation
리플 효과의 색상, 투명도, 지속 시간을 설정해요.
<PressableFeedback>
<PressableFeedback.Ripple
animation={{
backgroundColor: { value: '#ec4899' },
opacity: { value: [0, 0.1, 0] },
progress: { baseDuration: 600 },
}}
/>
...
</PressableFeedback>
Scale on a Specific Child (PressableFeedback.Scale)
루트 자체가 아니라 컨테이너 안의 특정 요소에 스케일 애니메이션을 적용해야 할 때, animation={false}로 루트의 내장 스케일을 비활성화하고 PressableFeedback.Scale 복합 파트를 사용해요. 이렇게 하면 어느 요소가 스케일될지 완벽하게 제어할 수 있고, 스케일 래퍼에 className/style을 직접 적용할 수 있어요.
<PressableFeedback animation={false}>
<PressableFeedback.Scale>...</PressableFeedback.Scale>
</PressableFeedback>
Scale 래퍼 안에서 Highlight나 Ripple과 결합할 수 있어요:
<PressableFeedback animation={false}>
<PressableFeedback.Scale>
<PressableFeedback.Highlight />
...
</PressableFeedback.Scale>
</PressableFeedback>
Disable All Animations
루트에 animation="disable-all"을 설정하면 내장 스케일과 자식 복합 파트(Scale, Highlight, Ripple)를 포함한 모든 애니메이션을 캐스케이드 비활성화해요.
<PressableFeedback animation="disable-all">...</PressableFeedback>
스케일 설정을 유지하면서 모든 애니메이션을 비활성화할 수도 있어요 (예: 런타임 토글용):
<PressableFeedback animation={{ scale: { value: 0.97 }, state: 'disable-all' }}>
...
</PressableFeedback>
Example
import { PressableFeedback, Card, Button } from 'heroui-native';
import { Image } from 'expo-image';
import { LinearGradient } from 'expo-linear-gradient';
import { StyleSheet, View, Text } from 'react-native';
export default function PressableFeedbackExample() {
return (
<PressableFeedback className="w-full aspect-square overflow-auto">
<Card className="flex-1">
<Image
source={{
uri: 'https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/neo2.jpeg',
}}
style={StyleSheet.absoluteFill}
contentFit="cover"
/>
<LinearGradient
colors={['rgba(0,0,0,0.1)', 'rgba(0,0,0,0.4)']}
style={StyleSheet.absoluteFill}
/>
<PressableFeedback.Ripple
animation={{
backgroundColor: { value: 'white' },
opacity: { value: [0, 0.3, 0] },
}}
/>
<View className="flex-1 gap-4" pointerEvents="box-none">
<Card.Body className="flex-1" pointerEvents="none">
<Card.Title className="text-base text-zinc-50 uppercase mb-0.5">
Neo
</Card.Title>
<Card.Description className="text-zinc-50 font-medium text-base">
Home robot
</Card.Description>
</Card.Body>
<Card.Footer className="gap-3">
<View className="flex-row items-center justify-between">
<View pointerEvents="none">
<Text className="text-base text-white">Available soon</Text>
<Text className="text-base text-zinc-300">Get notified</Text>
</View>
<Button size="sm" className="bg-white">
<Button.Label className="text-black">Notify me</Button.Label>
</Button>
</View>
</Card.Footer>
</View>
</Card>
</PressableFeedback>
);
}
더 많은 예시는 GitHub repository에서 찾을 수 있어요.
API Reference
PressableFeedback
| prop | type | default | 설명 |
|---|---|---|---|
children |
React.ReactNode |
- | 누름 피드백으로 감쌀 콘텐츠 |
isDisabled |
boolean |
false |
pressable 컴포넌트가 비활성화되었는지 여부 |
className |
string |
- | 추가 CSS 클래스 |
animation |
PressableFeedbackRootAnimation |
- | { scale: ... }로 스케일 커스텀, false로 루트 스케일 비활성화, 'disable-all'로 전체 캐스케이드 비활성화 |
isAnimatedStyleActive |
boolean |
true |
루트의 내장 애니메이션 스타일 활성 여부 |
asChild |
boolean |
false |
자식 요소로 렌더링할지 여부 |
...rest |
AnimatedProps<PressableProps> |
- | 모든 Reanimated Animated Pressable props가 지원돼요 |
PressableFeedbackRootAnimation
루트 애니메이션 prop은 표준 AnimationRoot 제어 흐름을 지원해요:
true또는undefined: 기본 내장 스케일 애니메이션 사용false또는"disabled": 루트의 내장 스케일 비활성화 (PressableFeedback.Scale로 스케일을 적용할 때 사용)"disable-all": 내장 스케일과 자식(Scale, Highlight, Ripple)을 포함한 모든 애니메이션 캐스케이드 비활성화object: 내장 스케일용 커스텀 설정
| prop | type | default | 설명 |
|---|---|---|---|
scale |
PressableFeedbackScaleAnimation |
- | 내장 스케일 애니메이션 커스텀 (value, timingConfig 등) |
state |
'disabled' | 'disable-all' | boolean |
- | 설정을 유지하면서 애니메이션 상태 제어 (예: 런타임 토글용) |
PressableFeedback.Scale
루트 자체 대신 컨테이너 안의 특정 자식 요소에 스케일을 적용해야 할 때 이 복합 파트를 사용해요. 이 컴포넌트를 사용할 때는 루트에 animation={false}를 설정해 내장 스케일을 비활성화해요.
| prop | type | default | 설명 |
|---|---|---|---|
className |
string |
- | 추가 CSS 클래스 |
animation |
PressableFeedbackScaleAnimation |
- | 스케일 효과용 애니메이션 설정 |
isAnimatedStyleActive |
boolean |
true |
애니메이션 스타일(react-native-reanimated) 활성 여부 |
style |
ViewStyle |
- | 추가 스타일 |
...AnimatedProps |
AnimatedProps<ViewProps> |
- | 모든 Reanimated Animated View props가 지원돼요 |
PressableFeedbackScaleAnimation
스케일 효과용 애니메이션 설정이에요. 다음 값을 가질 수 있어요:
false또는"disabled": 스케일 애니메이션 비활성화true또는undefined: 기본 스케일 애니메이션 사용object: 커스텀 스케일 설정
| prop | type | default | 설명 |
|---|---|---|---|
state |
'disabled' | boolean |
- | 속성을 커스텀하는 동안 애니메이션 비활성화 |
value |
number |
0.985 |
누름 시 스케일 값 (컨테이너 너비에 따라 자동 조정됨) |
timingConfig |
WithTimingConfig |
{ duration: 300, easing: Easing.out(Easing.ease) } |
애니메이션 타이밍 설정 |
ignoreScaleCoefficient |
boolean |
false |
자동 스케일 계수를 무시하고 스케일 값을 직접 사용 |
PressableFeedback.Highlight
| prop | type | default | 설명 |
|---|---|---|---|
className |
string |
- | 추가 CSS 클래스 |
animation |
PressableFeedbackHighlightAnimation |
- | 하이라이트 오버레이용 애니메이션 설정 |
isAnimatedStyleActive |
boolean |
true |
애니메이션 스타일(react-native-reanimated) 활성 여부 |
style |
ViewStyle |
- | 추가 스타일 |
...AnimatedProps |
AnimatedProps<ViewProps> |
- | 모든 Reanimated Animated View props가 지원돼요 |
PressableFeedbackHighlightAnimation
하이라이트 오버레이용 애니메이션 설정이에요. 다음 값을 가질 수 있어요:
false또는"disabled": 하이라이트 애니메이션 비활성화true또는undefined: 기본 애니메이션 사용object: 커스텀 애니메이션 설정
| prop | type | default | 설명 |
|---|---|---|---|
state |
'disabled' | boolean |
- | 속성을 커스텀하는 동안 애니메이션 비활성화 |
opacity.value |
[number, number] |
[0, 0.1] |
투명도 값 [unpressed, pressed] |
opacity.timingConfig |
WithTimingConfig |
{ duration: 200 } |
애니메이션 타이밍 설정 |
backgroundColor.value |
string |
테마 인식 회색 | 하이라이트 오버레이의 배경색 |
PressableFeedback.Ripple
| prop | type | default | 설명 |
|---|---|---|---|
className |
string |
- | 컨테이너 슬롯용 추가 CSS 클래스 |
classNames |
ElementSlots<RippleSlots> |
- | 슬롯용 추가 CSS 클래스 (container, ripple) |
styles |
Partial<Record<RippleSlots, ViewStyle>> |
- | 리플 오버레이의 다른 부분용 스타일 |
animation |
PressableFeedbackRippleAnimation |
- | 리플 오버레이용 애니메이션 설정 |
isAnimatedStyleActive |
boolean |
true |
애니메이션 스타일(react-native-reanimated) 활성 여부 |
...ViewProps |
Omit<ViewProps, 'style'> |
- | style을 제외한 모든 View props가 지원돼요 |
styles
| prop | type | 설명 |
|---|---|---|
container |
ViewStyle |
컨테이너 슬롯용 스타일 |
ripple |
ViewStyle |
리플 슬롯용 스타일 |
PressableFeedbackRippleAnimation
리플 오버레이용 애니메이션 설정이에요. 다음 값을 가질 수 있어요:
false또는"disabled": 리플 애니메이션 비활성화true또는undefined: 기본 애니메이션 사용object: 커스텀 애니메이션 설정
| prop | type | default | 설명 |
|---|---|---|---|
state |
'disabled' | boolean |
- | 속성을 커스텀하는 동안 애니메이션 비활성화 |
backgroundColor.value |
string |
테마를 기반으로 계산 | 리플 효과의 배경색 |
progress.baseDuration |
number |
1000 |
리플 진행의 기본 지속 시간 (대각선 길이에 따라 자동 조정됨) |
progress.minBaseDuration |
number |
750 |
리플 진행 애니메이션의 최소 기본 지속 시간 |
progress.ignoreDurationCoefficient |
boolean |
false |
자동 지속 시간 계수를 무시하고 기본 지속 시간을 직접 사용 |
opacity.value |
[number, number, number] |
[0, 0.1, 0] |
리플 애니메이션의 투명도 값 [start, peak, end] |
opacity.timingConfig |
WithTimingConfig |
{ duration: 200 } |
애니메이션 타이밍 설정 |
scale.value |
[number, number, number] |
[0, 1, 1] |
리플 애니메이션의 스케일 값 [start, peak, end] |
scale.timingConfig |
WithTimingConfig |
{ duration: 200 } |
애니메이션 타이밍 설정 |
ElementSlots<RippleSlots>
리플 슬롯용 추가 CSS 클래스예요:
| slot | 설명 |
|---|---|
container |
바깥 컨테이너 슬롯 (absolute inset-0) - 스타일을 자유롭게 커스텀할 수 있어요 |
ripple |
안쪽 리플 슬롯 (absolute top-0 left-0 rounded-full) - className으로 설정할 수 없는 애니메이션 속성이 있어요 |