> 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 tied to user interaction**we cover. Like scrolling, keyboards, audio focus, and haptic feedback, **features that must respond immediately to user actions**we bring them together and explain them in one place.

***

### Scroll bounce area background handling

**SDK components:** `ScrollViewInertialBackground`

iOS `ScrollView`It is a component that fills the background color in the \*\*bounce effect area (top/bottom)\*\* that appears when scrolling reaches the end in a ScrollView, 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`

    This is the background color to apply to the upper area of the scroll. The default is `adaptive.background`applied automatically to match the system theme.
  * **props.bottomColor** · `string`

    This is the background color to apply to the lower area of the scroll. The default is `adaptive.background`applied automatically to match the system theme.
  * **props.spacer** · `number`

    Specifies the size of the space between the top and bottom spaces around the content where the background color will be applied. The default is [`useWindowDimensions`](https://reactnative.dev/docs/next/usewindowdimensions)uses the screen height obtained from

**Example: Add background colors above and below a scroll view**

Add a red background above the scroll view and a blue background below it. The background color is applied to areas outside the scrolled content.

```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`

The current device's **color mode (light / dark)** is a type representing it. Used for theme branching or style conditions.

**Signature**

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

***

### Lift elements above the keyboard

**SDK components:** `KeyboardAboveView`

When the keyboard appears **A layout component that automatically lifts child components above the keyboard**. It's useful when you want buttons or action areas to stay 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

  This is the component to display above the keyboard when it appears. For example, you can put buttons, text inputs, and so on.

**Return value**

* ReactElement

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

**Example: Lift 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 video or audio components, **the callback type called when audio focus changes**. It lets you control how interruptions caused by other apps or system events are handled.

**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.

***

### Trigger haptic feedback

**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.

**Signature**

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

**Return value**

* void

**Example: Trigger 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 feedback 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 **directly affect the user experience**. Avoid overuse and use them only at meaningful moments.
* Keyboard / audio / haptic features may behave differently depending on the platform.
* Event- or callback-based features must **cleanup** be implemented together with cleanup logic.


---

# 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.
