suiss/uim · Block

Permission Primer

A screen that explains why the app needs a permission before asking, with Allow and Not now buttons.

Permission Primer is an open-source mobile screen from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Permission Primer on iOS in light mode

A primer shown before a system permission prompt: a large icon, a title, a description and a list of benefits, each with its own icon. Allow and Not now buttons sit in a BottomBar. By default it asks for notifications.

Installation

$ pnpm dlx @esuiss/uim@latest add permission-primer

The CLI also adds what it builds on: Bottom Bar, Button, Icon, Screen, Text.

Manual

  1. Install the dependencies:
npx expo install phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Bottom Bar, Button, Icon, Screen, Text.

  2. Copy the source into components/blocks/permission-primer.tsx:

uniwind/components/blocks/permission-primer.tsx
import {
  BellIcon,
  ChatCircleIcon,
  ClockIcon,
  PackageIcon,
  type Icon as PhosphorIcon,
} from "phosphor-react-native"
import { ScrollView, View } from "react-native"
import { BottomBar, BottomBarContent } from "@/components/ui/bottom-bar"
import { Button } from "@/components/ui/button"
import { Icon } from "@/components/ui/icon"
import { Screen } from "@/components/ui/screen"
import { Text } from "@/components/ui/text"

type PermissionPrimerBenefit = {
  icon: PhosphorIcon
  1. Update the import paths to match your project.

Usage

import { PermissionPrimer } from "@/components/blocks/permission-primer"
<PermissionPrimer />

Every piece is a prop: icon, title, description, benefits, allowLabel and dismissLabel. Request the real permission in onAllow and close the screen in onDismiss.