> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/react-native/interaction.md).

# Response handling

In this document, **UI/UX features directly connected to user interaction**are covered. Such as scrolling, keyboard, audio focus, and haptic vibration, **features that must respond immediately to user actions**are gathered in one place and explained.

***

### Background handling for the scroll bounce area

**SDK Component:** `ScrollViewInertialBackground`

iOS `ScrollView`is a component that fills the \*\*bounce effect area (top/bottom)\*\* that appears when scrolling reaches the end with background color, providing a more natural visual effect.

**Signature**

```ts
function ScrollViewInertialBackground({
  topColor,
  bottomColor,
  spacer: _spacer,
}: ScrollViewInertialBackgroundProps): JSX.Element;
```

**Parameters**

* props object

  passed to the component `props` object.

  * **props.topColor** · `string`

    The background color applied to the area above the scroll. The default is `adaptive.background`, which is automatically applied according to the system theme.
  * **props.bottomColor** · `string`

    The background color applied to the area below the scroll. The default is `adaptive.background`, which is automatically applied according to the system theme.
  * **props.spacer** · `number`

    Specify the size of the space between the content where the background color is applied, above and below. The default is [`useWindowDimensions`](https://reactnative.dev/docs/next/usewindowdimensions)the screen height obtained from it.

**Example: Adding background colors above and below a ScrollView**

Add a red background above the ScrollView and a blue background below it. The background color is applied to the area outside the scroll.

```tsx
import { ScrollView, View, Text } from 'react-native';
import { ScrollViewInertialBackground } from '@granite-js/react-native';

const dummies = Array.from({ length: 20 }, (_, i) => i);

function InertialBackgroundExample() {
  return (
    <ScrollView>
      <ScrollViewInertialBackground topColor="red" bottomColor="blue" />
      {dummies.map((i) => (
        <View
          key={`dummy-${i}`}
          style={{ width: '100%', height: 100, borderBottomColor: 'black', borderBottomWidth: 1 }}
        >
          <Text>Try scrolling.</Text>
        </View>
      ))}
    </ScrollView>
  );
}
```

***

### Color mode type

**SDK API:** `ColorPreference`

Type representing the device's current **color mode (light / dark)** used for theme branching or style condition handling.

**Signature**

```typescript
type ColorPreference = 'light' | 'dark';
```

***

### Lifting an element above the keyboard

**SDK Component:** `KeyboardAboveView`

When the keyboard appears **a layout component that automatically lifts child components above the keyboard**is useful when you want buttons or action areas to always remain visible even while typing.

**Signature**

```typescript
function KeyboardAboveView({ style, children, ...props }: ComponentProps<typeof View>): ReactElement;
```

**Parameters**

* props.styleStyleProp\<ViewStyle>

  You can apply additional styles. For example, you can set background color or size.
* props.childrenReactNode

  Components to display above the keyboard when it appears. For example, you can put buttons, text input fields, and so on.

**Return value**

* ReactElement

  Adjusted above the keyboard when the keyboard appears [`Animated.View`](https://reactnative.dev/docs/animated#createanimatedcomponent)returns it.

**Example: Lifting an element above the keyboard**

```tsx
import { ScrollView, TextInput, View, Text } from 'react-native';
import { KeyboardAboveView } from '@granite-js/react-native';

function KeyboardAboveViewExample() {
  return (
    <>
      <ScrollView>
        <TextInput placeholder="placeholder" />
      </ScrollView>

      <KeyboardAboveView>
        <View style={{ width: '100%', height: 50, backgroundColor: 'yellow' }}>
          <Text>It's above the keyboard.</Text>
        </View>
      </KeyboardAboveView>
    </>
  );
}
```

***

### Audio focus change callback

**SDK API:** `OnAudioFocusChanged`

of a video or audio component **a callback type called when audio focus changes**You can control the handling when sound is interrupted by another app or a system event.

**Signature**

```typescript
type OnAudioFocusChanged = NonNullable<VideoProperties['onAudioFocusChanged']>;
```

**Parameters**

* **event** · Required · `Object`

  An event object containing audio focus information.

  * **event.hasAudioFocus** · Required · `boolean`

    Indicates whether the video component has audio focus.

***

### Running haptic vibration

**SDK Function:** `generateHapticFeedback`

on the device **a function that triggers haptic feedback**Use it when tactile feedback is needed, such as button clicks, completion notifications, or success/failure feedback.

Haptics will only work if the setting is enabled in the Toss app under Settings > Vibration.

**Signature**

```typescript
function generateHapticFeedback(options: HapticFeedbackOptions): Promise<void>;
```

**Return value**

* void

**Example: Triggering haptics by pressing a button**

{% tabs %}
{% tab title="js" %}

```js
import { generateHapticFeedback } from '@apps-in-toss/web-framework';

generateHapticFeedback({ type: 'tickWeak' });
```

{% endtab %}

{% tab title="React" %}

```tsx
import React from 'react';
import { generateHapticFeedback } from '@apps-in-toss/web-framework';

function GenerateHapticFeedbackWeb() {
  return (
    <button
      onClick={() => {
        generateHapticFeedback({ type: 'tickWeak' });
      }}
      style={{
        padding: '10px 20px',
        borderRadius: '8px',
        border: 'none',
        backgroundColor: '#3182f6',
        color: 'white',
        cursor: 'pointer',
        fontSize: '16px',
      }}
    >
      Haptic
    </button>
  );
}

export default GenerateHapticFeedbackWeb;
```

{% endtab %}

{% tab title="React Native" %}

```tsx
import { Button } from 'react-native';
import { generateHapticFeedback } from '@apps-in-toss/framework';

function GenerateHapticFeedback() {
  return (
    <Button
      title="Haptic"
      onPress={() => {
        generateHapticFeedback({ type: 'tickWeak' });
      }}
    />
  );
}
```

{% endtab %}
{% endtabs %}

**Try the example app**

[apps-in-toss-examples](https://github.com/toss/apps-in-toss-examples) from the repository [with-haptic-feedback](https://github.com/toss/apps-in-toss-examples/tree/main/with-haptic-feedback) Download the code or scan the QR code below to try it yourself.

QR code link: intoss\://with-haptic-feedback

### Haptic vibration options and types

**Type:** `HapticFeedbackOptions`, `HapticFeedbackType`

`generateHapticFeedback`Defines the vibration type options to pass to

**Signature**

```tsx
interface HapticFeedbackOptions {
  type: HapticFeedbackType;
}

type HapticFeedbackType =
  | 'tickWeak'
  | 'tap'
  | 'tickMedium'
  | 'softMedium'
  | 'basicWeak'
  | 'basicMedium'
  | 'success'
  | 'error'
  | 'wiggle'
  | 'confetti';
```

### Notes

* Interaction-related features **have a direct impact on**the user experience. Avoid overuse and use only at meaningful moments.
* Keyboard / audio / haptic features may behave differently depending on the platform.
* Event- or callback-based features must always include **cleanup** logic as well.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/react-native/interaction.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
