Retours haptiques iPhone

VérifiéSûr

Ajoute des retours tactiles (haptics) aux interactions UI avec expo-haptics, en synchronisant avec le design Liquid Glass pour une expérience immersive.

Spar Skills Guide Bot
DeveloppementIntermédiaire
2002/06/2026
Claude Code
#haptics#expo#react-native#mobile-ui#user-experience

Recommandé pour

Notre avis

Ajoute des retours haptiques (vibrations tactiles) aux interactions UI dans une application iPhone utilisant Expo, via le module expo-haptics.

Points forts

  • Intègre facilement des retours haptiques standardisés aux éléments interactifs (Pressable, Switch, etc.)
  • Propose des types de haptiques adaptés à chaque action (impact léger, sélection, notification succès/erreur)
  • Gère automatiquement le fallback Android, pas besoin de code spécifique à la plateforme
  • S'intègre avec le design Liquid Glass pour un feedback visuo-tactile cohérent

Limites

  • Nécessite que expo-haptics soit installé au préalable
  • Le comportement haptique peut varier selon les modèles d'iPhone et les versions d'iOS
  • Un usage excessif peut nuire à l'expérience utilisateur ; la règle de bonne pratique est incluse mais doit être respectée
Quand l'utiliser

Lorsque vous souhaitez améliorer l'expérience utilisateur en ajoutant des retours tactiles aux interactions clés comme les boutons, les toggles, les soumissions de formulaire ou les notifications de résultat.

Quand l'éviter

Évitez de l'utiliser pour des événements très fréquents comme le défilement, des glissements mineurs ou des animations continues, sous peine de créer une gêne.

Analyse de sécurité

Sûr
Score qualité90/100

The skill provides guidance on adding haptic feedback using expo-haptics. It only runs 'npx expo install expo-haptics' via Bash for package installation, which is legitimate and non-destructive. No data exfiltration, system destruction, or obfuscation is involved.

Aucun point d'attention détecté

Exemples

Add haptics to all pressable elements
ハプティクス追加して。全てのPressableにLight Impactを追加して。
Add haptics to a specific button
いいねボタンに触覚フィードバックを追加して。軽いインパクトで。
Add success/error haptics to form submission
ログインフォームの送信時に成功ならSuccess、失敗ならErrorのハプティクスを追加して。

name: haptics description: iPhoneの触覚フィードバック(ハプティクス)をUIに追加する。「ハプティクス追加して」「触覚フィードバック」「タップ感を出して」などのリクエストで使用する。 allowed-tools: Read, Write, Edit, Glob, Grep, Bash argument-hint: [対象画面名 or 省略で全画面]

ハプティクス追加スキル

expo-haptics を使用して、iPhoneユーザーに適切な触覚フィードバックを提供する。

デザイン前提: Liquid Glass

本プロジェクトは @callstack/liquid-glass による Liquid Glass デザインを前提とする。 ハプティクスとガラスエフェクトの連携:

  • LiquidGlassViewinteractive プロパティは、タッチ時にガラスの視覚アニメーションを発生させる。これに ハプティクス(Light Impact)を同時に発火 させることで、視覚+触覚の統一的なフィードバックを実現する
  • ガラスカードのタップ: interactive={true} + Haptics.impactAsync(Light) をセットで使う
  • ガラス要素の effect 切り替え時(マテリアライズ/デマテリアライズ アニメーション)にも Haptics.selectionAsync() を付与する

前提条件

expo-haptics がインストールされていること。未インストールの場合は先にインストールする:

npx expo install expo-haptics

手順

1. 対象の特定

以下のインタラクティブ要素を含むファイルを検索する:

  • Pressable, TouchableOpacity, TouchableHighlight
  • Switch, Slider
  • カスタムボタンコンポーネント

2. ハプティクスの種類と適用ルール

| 操作 | ハプティクスタイプ | 関数 | |------|-------------------|------| | 通常のボタンタップ | Light Impact | Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light) | | 重要なアクション(送信, 保存) | Medium Impact | Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium) | | タブ切り替え / セグメント選択 | Selection | Haptics.selectionAsync() | | トグル(Switch)ON/OFF | Selection | Haptics.selectionAsync() | | 成功(ログイン成功, 投稿完了) | Success Notification | Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success) | | エラー(認証失敗, バリデーション) | Error Notification | Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error) | | 警告(削除確認, 破壊的操作) | Warning Notification | Haptics.notificationAsync(Haptics.NotificationFeedbackType.Warning) | | ロングプレス開始 | Heavy Impact | Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Heavy) |

3. 実装パターン

パターンA: Pressable のonPressに直接追加

import * as Haptics from 'expo-haptics';

<Pressable
  onPress={() => {
    Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
    // 既存のonPress処理
    handlePress();
  }}
>

パターンB: カスタムボタンコンポーネントに組み込み

import * as Haptics from 'expo-haptics';

interface Props {
  onPress: () => void;
  hapticStyle?: Haptics.ImpactFeedbackStyle;
  // ... 既存のprops
}

export const HapticButton: React.FC<Props> = ({
  onPress,
  hapticStyle = Haptics.ImpactFeedbackStyle.Light,
  ...rest
}) => {
  const handlePress = () => {
    Haptics.impactAsync(hapticStyle);
    onPress();
  };
  // ...
};

パターンC: 非同期処理の成功/失敗時

const handleSubmit = async () => {
  try {
    await submitForm();
    Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
  } catch (error) {
    Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error);
  }
};

4. 適用優先度

  1. 必須: 削除ボタン(Warning)、認証送信(Success/Error)
  2. 推奨: ナビゲーションボタン(Light)、タブバー(Selection)、いいねボタン(Light)
  3. 任意: 装飾的なプレス(例: カード選択)

ルール

  • ハプティクスは onPress先頭で呼び出す(ユーザーが即座にフィードバックを感じるため)
  • 非同期処理の結果に応じたフィードバックは処理完了後に呼び出す
  • 過剰なハプティクスは避ける(スクロールや頻繁なイベントには付けない)
  • Android では expo-haptics が自動的にフォールバックするため、Platform分岐は不要
  • 既存のボタンコンポーネント(GradientPillButton, OutlinePillButton)がある場合は、そこに一括で組み込むことを優先する
  • import * as Haptics from 'expo-haptics' の形式でインポートする
Skills similaires