> 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/common/screen/safe-area.md).

# Safe Area

On mobile browsers, content can sometimes be obscured by system UI such as the status bar or home indicator. The Appintos SDK provides a function that calculates the safe area padding values for the screen in pixels to prevent this.

In particular, on devices like iPhone X and later, or some Android devices, system UI often covers content in web apps that use full-screen mode. Using the function below makes it easy to adjust padding so content is displayed safely.

### `SafeAreaInsets`

When the screen mode changes `safearea` You can check the values. When switching screens, you can retrieve safe area information or subscribe to changes. Using this feature lets you implement a stable UI across various device environments.

* `SafeAreaInsets.get()` of the current screen mode `safearea` Gets the value.
* `SafeAreaInsets.subscribe()` Every time the screen mode changes `safearea` Subscribes to value changes.

{% hint style="info" %}
**In-game X button coordinates**

The X button is provided by default in the framework. On the **top right**of the screen, and its position can be calculated as follows.

* **X-axis:** `safeAreaInsetsValue.right + 10`
* **Y-axis:** `safeAreaInsetsValue.top + 5` (iOS) / `safeAreaInsetsValue.top +10` (Android)

If an in-game button overlaps with the framework's X button, it may be rejected during review.
{% endhint %}

#### Examples

```tsx
import { SafeAreaInsets } from '@apps-in-toss/web-framework';
import { useEffect, useState } from 'react';

interface SafeAreaInsets {
  top: number;
  bottom: number;
  left: number;
  right: number;
}

function Page() {
  const [safeAreaInsetsValue, setSafeAreaInsetsValue] = useState<SafeAreaInsets>(() => SafeAreaInsets.get());
  // Navigation bar top padding: safeAreaInsetsValue.top
  // Navigation bar right padding: safeAreaInsetsValue.right + 10

  useEffect(() => {
    const cleanup = SafeAreaInsets.subscribe({
      onEvent: (insets) => {
        setSafeAreaInsetsValue(insets);
      },
    });
    return () => cleanup();
  }, []);

  // ...
}
```

### `getSafeAreaInsets`

{% hint style="info" %}
**This function can only be used up to SDK version 1.4.6**

**Deprecated starting from version 1.4.7** has been
{% endhint %}

```ts
import { getSafeAreaInsets } from '@apps-in-toss/web-framework';

const insets = getSafeAreaInsets();
// Example return value: { top: 44, bottom: 34 }
```

The returned object includes the following properties.

* `top`: This is the space that must be kept clear so it isn't covered by the top status bar.
* `bottom`: This is the space that must be kept clear so it isn't covered by the bottom home indicator.

This value is often used when building UI for the entire screen (`viewport`) and is often used when building UI to fit the screen. For example, you can add padding to a bottom-fixed button or keep a top header from overlapping the status bar.

#### Example of applying bottom padding

This is an example of adding padding so a bottom-fixed button doesn't overlap the home indicator.

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

const insets = getSafeAreaInsets();

const Button = () => {
  return (
    <div style={{ paddingBottom: `${insets.bottom}px` }}>
      <button>Confirm</button>

  );
};
```

#### Example of applying top padding

This is an example of adding padding so a top-fixed header doesn't overlap the status bar.

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

const insets = getSafeAreaInsets();

const Header = () => {
  return (
    <div style={{ paddingTop: `${insets.top}px` }}>
      <h1>Title</h1>

  );
};
```

### `useSafeAreaInsets`

To prevent content from being obscured by system UI such as the status bar or home indicator on mobile browsers, it calculates the screen's safe area padding values in pixels. `useSafeAreaInsets` can be used when developing with React Native.

```tsx
import { useSafeAreaInsets } from '@granite-js/native/react-native-safe-area-context';
const { top: safeAreaTop, right: safeAreaRight } = useSafeAreaInsets();
// Top navbar padding: safeAreaTop
// Right navbar padding: safeAreaRight + 10
```


---

# 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/common/screen/safe-area.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.
