suiss/uim · React Native Component

Header

A navigation bar with a back button, a centered title, actions and an optional large title that collapses on scroll.

Header is an open-source mobile component 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
Header on iOS in light mode

Header is a 44-point bar that sorts its children into three slots: HeaderBack and leading HeaderActions on the start side, HeaderTitle in the center, and everything else on the end side. The side slots share the remaining width equally, so the title stays centered.

For a large title, create a scroll state with useHeaderScroll(), pass it to both Header and HeaderScrollView, and put a HeaderLargeTitle at the top of the scroll view. As the large title scrolls away, the small title fades in and a hairline appears under the bar. Pulling down stretches the large title slightly.

Installation

$ pnpm dlx @esuiss/uim@latest add header

The CLI also adds what it builds on: Icon, Text.

Manual

  1. Install the dependencies:
npx expo install cn phosphor-react-native react-native-reanimated react-native-svg react-native-worklets
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the source into components/ui/header.tsx:

uniwind/components/ui/header.tsx
import { cn } from "cn"
import { CaretLeftIcon } from "phosphor-react-native"
import * as React from "react"
import {
  I18nManager,
  Pressable,
  type ScrollViewProps,
  View,
  type ViewProps,
} from "react-native"
import Animated, {
  interpolate,
  type SharedValue,
  useAnimatedScrollHandler,
  useAnimatedStyle,
  useSharedValue,
  1. Update the import paths to match your project.

Usage

import { Header, HeaderTitle, HeaderLargeTitle, HeaderBack, HeaderActions, HeaderScrollView } from "@/components/ui/header"
<View className="-mx-4 -mt-4">
  <Header>
    <HeaderBack>Settings</HeaderBack>
    <HeaderTitle>Profile</HeaderTitle>
    <HeaderActions>
      <Button variant="plain" size="sm">
        <Text className="font-semibold">Edit</Text>
      </Button>
    </HeaderActions>
  </Header>
</View>

HeaderBack shows a caret and an optional text label such as the previous screen's name; wire onPress to your navigation. Group icon buttons in HeaderActions, and set side="leading" to place a group on the start side.

Both HeaderTitle and HeaderLargeTitle accept a subtitle. Plain strings are wrapped in Text and truncated to one line in the bar.

Without a large title, you can still pass the same scroll to Header and HeaderScrollView to show the hairline once content scrolls under the bar.

Examples

Large title

A large title that collapses into the bar on scroll.

iOS
Header (large title) on iOS in light mode

Large title with subtitle

A large title with a subtitle.

iOS
Header (large title with subtitle) on iOS in light mode

Compact with scroll

A compact title whose hairline appears on scroll.

iOS
Header (compact with scroll) on iOS in light mode

Subtitle

A two-line title with a subtitle.

iOS
Header (subtitle) on iOS in light mode

Leading actions

Actions on both sides of the title.

iOS
Header (leading actions) on iOS in light mode

Back only

A long back label that truncates.

iOS
Header (back only) on iOS in light mode

API Reference

Bar that lays out the back button, title and actions.

ExtendsViewProps
PropType
About
Scroll state from useHeaderScroll().
Type
HeaderScroll
Default
—

HeaderTitle

Centered title with optional subtitle.

ExtendsViewProps
PropType
About
Second line under the title.
Type
React.ReactNode
Default
—

HeaderLargeTitle

Large title at the top of the scroll content.

ExtendsViewProps
PropType
About
Line under the large title.
Type
React.ReactNode
Default
—

HeaderBack

Back button with a caret and optional label.

ExtendsReact.ComponentProps<typeof Pressable>
PropType
Type
React.ReactNode
Default
—

HeaderActions

Row of actions for either side.

ExtendsViewProps
PropType
About
leading or trailing. Defaults to trailing.
Type
"leading""trailing"
Default
"trailing"

HeaderScrollView

Scroll view that drives the header animations.

ExtendsScrollViewProps
PropType
About
Scroll state from useHeaderScroll().
Type
HeaderScroll
Default
required

Accessibility

  • HeaderTitle and a string HeaderLargeTitle have the heading role.
  • HeaderBack has the button role and is labelled with its text, or "Back" when it has none.
  • Give icon-only actions an accessibilityLabel.

Notes

  • The back caret rotates and the large title scales from the correct edge in right-to-left layouts.
  • Uses text-link, bg-separator and bg-item-pressed tokens; light and dark follow the system appearance.