Skip to content

Haptic Component ​

The HapticComponent provides access to native haptic feedback (vibration) on the device.

Basic Info ​

Description ​

This component allows the web application to trigger various haptic feedback patterns, such as light taps, heavy impacts, or success/error vibrations.

How to Use ​

1. Web Implementation ​

javascript
import { useHaptic } from '@bagisto-native/react';

const MyComponent = () => {
    const { triggerHaptic } = useHaptic();

    const onButtonPress = () => {
        triggerHaptic("light");
    };

    const onSuccess = () => {
        triggerHaptic("success");
    };

    const onError = () => {
        triggerHaptic("error");
    };

    return (
        <div>
            <button onClick={onButtonPress}>Tap</button>
            <button onClick={onSuccess}>Success</button>
            <button onClick={onError}>Error</button>
        </div>
    );
};

2. Native Side ​

kotlin
navigator.registerBridgeComponent("haptic", HapticComponent(this))

API Reference ​

ParameterTypeDescription
typeString"light", "medium", "heavy", "success", "error", "warning"

Next Steps ​

Released under the MIT License.