# react-native-spacer-view

> test

Latest version **0.1.3** (published 2025-01-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-spacer-view
pnpm add react-native-spacer-view
yarn add react-native-spacer-view
bun add react-native-spacer-view
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2025-01-21 |
| First published | 2023-02-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 18 |
| Dependencies | 0 |
| Unpacked size | 21.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | John Haupenthal |
| Maintainers | johnhaup |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-spacer-view
- Repository: https://github.com/johnhaup/react-native-spacer-view
- Homepage: https://github.com/johnhaup/react-native-spacer-view#readme
- Issues: https://github.com/johnhaup/react-native-spacer-view/issues
- npm.io page: https://npm.io/package/react-native-spacer-view

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2025-01-21
- 0.1.2 — 2023-02-11
- 0.1.1 — 2023-02-11
- 0.1.0 — 2023-02-11

## README

<div align="center">
  <h1>react-native-spacer-view</h1>
  <a href="https://www.youtube.com/watch?v=AZ93S78Nh4E">
    <img alt="cool alien" width=150 src="space-alien.svg">
  </a>
  <p>A little helper view to give you granular control over your layouts.</p>
</div>
<hr />

[![CI](https://github.com/johnhaup/react-native-spacer-view/actions/workflows/ci.yml/badge.svg)](https://github.com/johnhaup/react-native-spacer-view/actions/workflows/ci.yml)

## Installation

```sh
yarn add react-native-spacer-view
```

#### Note

This component depends on safe area insets provided by [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context). If you don't have this library installed, you'll need to add it and [wrap the root of your app in SafeAreaProvider](https://github.com/th3rdwave/react-native-safe-area-context#providers).

## API

Extends [ViewProps](https://reactnative.dev/docs/view#props). Note that view props are applied _last_, so they will take precendence over Spacer's props. For example, if you pass `flex={2}` and `style={{ flex: 5 }}`, the `flex: 5` will win out.

_All props are optional._

| Prop       | Type               | Description                                                                            |
| ---------- | ------------------ | -------------------------------------------------------------------------------------- |
| height     | `number`           | Adds to total `height` of Spacer.                                                      |
| width      | `number`           | Adds to total `width` of Spacer.                                                       |
| safeTop    | `boolean`          | Adds the device's top safe area inset to the total height of Spacer.                   |
| safeBottom | `boolean`          | Adds the device's bottom safe area inset to the total height of Spacer.                |
| flex       | `true` or `number` | Passing `true` gives Spacer `flex: 1`, passing a number gives Spacer `flex: [number]`. |

## Usage

```js
import { ScrollView } from 'react-native';
import { Spacer } from 'react-native-spacer-view';
import { Content, Footer, Header } from './components';

export function MyNeatScreen() {
  return (
    <ScrollView>
      <Spacer safeTop height={16} />
      <Header />
      <Spacer height={16} />
      <Content />
      <Spacer height={16} />
      <Footer />
      <Spacer safeBottom height={24} />
    </ScrollView>
  );
}
```

## Example App

You can run an [example](example/src/App.tsx) implementation of how you might use `Spacer` in a `FlatList` by cloning this repo and running the following commands:

```sh
cd example
yarn
yarn ios (or yarn android)
```

## License

MIT

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)

---
_Source: https://npm.io/package/react-native-spacer-view · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
