PressableFeedback

Container component that provides visual feedback for press interactions with automatic scale animation.

Import

import { PressableFeedback } from 'heroui-native';

Usage

Basic Usage

The PressableFeedback component wraps content to provide press feedback effects. By default, it applies a subtle scale animation when pressed.

<PressableFeedback>...</PressableFeedback>

Highlight Effect

Add a highlight overlay component for iOS-style feedback effect. The highlight uses the root's press state from context.

<PressableFeedback>
  <PressableFeedback.Highlight />
  ...
</PressableFeedback>

Ripple Effect

Add a ripple overlay component for Android-style feedback effect that emanates from the press point.

<PressableFeedback>
  <PressableFeedback.Ripple />
  ...
</PressableFeedback>

Custom Scale Animation

Customize or disable the default scale animation on press.

<PressableFeedback
  animation={{
    scale: {
      value: 0.9,
      timingConfig: { duration: 150 },
    },
  }}
>
  ...
</PressableFeedback>

Custom Highlight Animation

Configure highlight overlay opacity and background color.

<PressableFeedback>
  <PressableFeedback.Highlight
    animation={{
      opacity: { value: [0, 0.2] },
      backgroundColor: { value: '#3b82f6' },
    }}
  />
  ...
</PressableFeedback>

Custom Ripple Animation

Configure ripple effect color, opacity, and duration.

<PressableFeedback>
  <PressableFeedback.Ripple
    animation={{
      backgroundColor: { value: '#ec4899' },
      opacity: { value: [0, 0.1, 0] },
      progress: { baseDuration: 600 },
    }}
  />
  ...
</PressableFeedback>

Example

import { PressableFeedback, Card, Button } from 'heroui-native';
import { Image } from 'expo-image';
import { LinearGradient } from 'expo-linear-gradient';
import { StyleSheet, View } from 'react-native';

export default function PressableFeedbackExample() {
  return (
    <PressableFeedback className="w-full aspect-square rounded-3xl">
      <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>
  );
}

You can find more examples in the GitHub repository.

API Reference

PressableFeedback

proptypedefaultdescription
childrenReact.ReactNode-Content to be wrapped with press feedback
isDisabledbooleanfalseWhether the pressable component is disabled
classNamestring-Additional CSS classes
animationPressableFeedbackRootAnimation-Animation configuration for scale animation only
isAnimatedStyleActivebooleantrueWhether animated styles (react-native-reanimated) are active
...AnimatedPropsAnimatedProps<PressableProps>-All Reanimated Animated Pressable props are supported

PressableFeedbackRootAnimation

Animation configuration for PressableFeedback root component (scale only). Can be:

  • false or "disabled": Disable only root animations
  • "disable-all": Disable all animations including children
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
state'disabled' | 'disable-all' | boolean-Disable animations while customizing properties
scale.valuenumber0.985Scale value when pressed (automatically adjusted based on container width)
scale.timingConfigWithTimingConfig{ duration: 300, easing: Easing.out(Easing.ease) }Animation timing configuration
scale.ignoreScaleCoefficientbooleanfalseIgnore automatic scale coefficient and use the scale value directly

PressableFeedback.Highlight

proptypedefaultdescription
classNamestring-Additional CSS classes
animationPressableFeedbackHighlightAnimation-Animation configuration for highlight overlay
isAnimatedStyleActivebooleantrueWhether animated styles (react-native-reanimated) are active
styleViewStyle-Additional styles
...AnimatedPropsAnimatedProps<ViewProps>-All Reanimated Animated View props are supported

PressableFeedbackHighlightAnimation

Animation configuration for highlight overlay. Can be:

  • false or "disabled": Disable highlight animations
  • "disable-all": Disable all animations including children
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
state'disabled' | boolean-Disable animations while customizing properties
opacity.value[number, number][0, 0.1]Opacity values [unpressed, pressed]
opacity.timingConfigWithTimingConfig{ duration: 200 }Animation timing configuration
backgroundColor.valuestringTheme-aware grayBackground color of highlight overlay

PressableFeedback.Ripple

proptypedefaultdescription
classNamestring-Additional CSS classes for container slot
classNamesElementSlots<RippleSlots>-Additional CSS classes for slots (container, ripple)
containerStyleViewStyle-Style for the container slot
rippleStyleViewStyle-Style for the ripple slot
animationPressableFeedbackRippleAnimation-Animation configuration for ripple overlay
isAnimatedStyleActivebooleantrueWhether animated styles (react-native-reanimated) are active
...ViewPropsOmit<ViewProps, 'style'>-All View props except style are supported

PressableFeedbackRippleAnimation

Animation configuration for ripple overlay. Can be:

  • false or "disabled": Disable ripple animations
  • "disable-all": Disable all animations including children
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
state'disabled' | boolean-Disable animations while customizing properties
backgroundColor.valuestringComputed based on themeBackground color of ripple effect
progress.baseDurationnumber1000Base duration for ripple progress (automatically adjusted based on diagonal)
progress.minBaseDurationnumber750Minimum base duration for the ripple progress animation
progress.ignoreDurationCoefficientbooleanfalseIgnore automatic duration coefficient and use base duration directly
opacity.value[number, number, number][0, 0.1, 0]Opacity values [start, peak, end] for ripple animation
opacity.timingConfigWithTimingConfig{ duration: 200 }Animation timing configuration
scale.value[number, number, number][0, 1, 1]Scale values [start, peak, end] for ripple animation
scale.timingConfigWithTimingConfig{ duration: 200 }Animation timing configuration

ElementSlots<RippleSlots>

Additional CSS classes for ripple slots:

slotdescription
containerOuter container slot (absolute inset-0) - styles can be fully customized
rippleInner ripple slot (absolute top-0 left-0 rounded-full) - has animated properties that cannot be set via className

On this page