Skip to main content

Header

A screen's top bar: a back button, the title and actions. On iOS the title is centred in a 44pt bar with a "Back" label beside the chevron; in Material it's a 64dp top app bar with the title at the start; on the web it's a bordered bar. size="large" adds a big title under the bar.

Import
import { Header } from 'patine-ui';
Subpath
patine-ui/header
Source
GitHubMarkdown for LLMs
Runs on
iOSAndroidWebFree · MIT
Loading…
<Header
  title="Settings"
  onBack={() => {}}
  actions={
    <Button variant="ghost" size="sm">
      Edit
    </Button>
  }
/>

Try the props​

Props
title
subtitle
onBack
backLabel
actions
size
design
<Header title="Settings" onBack={goBack} />

Examples​

Each example is live: edit the code and it runs.

A photo album in select mode​

A photo album's header has two states. Normally it shows the album and a Select button; in select mode the title counts the picks, Cancel takes the back button's place, and the actions act on the selection.

Loading…
<Box border radius="lg" style={{ width: '100%', maxWidth: 400, overflow: 'hidden' }}>
  {selecting ? (
    <Header
      title={picked.length ? `${picked.length} selected` : 'Select photos'}
      leading={<Button variant="ghost" size="sm" onPress={done}>Cancel</Button>}
      actions={
        <HStack gap="xs">
          <Button size="icon" variant="ghost" accessibilityLabel="Share selected" disabled={!picked.length}>
            <Icon name="share" />
          </Button>
          <Button
            size="icon"
            variant="ghost"
            accessibilityLabel="Delete selected"
            disabled={!picked.length}
            onPress={() => {
              setPhotos((all) => all.filter((id) => !picked.includes(id)));
              done();
            }}
          >
            <Icon name="trash" color="danger" />
          </Button>
        </HStack>
      }
    />
  ) : (
    <Header title="Lisbon" subtitle={`${photos.length} photos`} onBack={() => {}} actions={<Button variant="ghost" size="sm" onPress={() => setSelecting(true)}>Select</Button>} />
  )}
  <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 2 }}>
    {photos.map((id) => (
      <Pressable
        key={id}
        disabled={!selecting}
        onPress={() => toggle(id)}
        accessibilityRole={selecting ? 'checkbox' : 'image'}
        accessibilityState={{ checked: picked.includes(id) }}
        accessibilityLabel={`Photo ${id}`}
        style={{ width: '32.8%', aspectRatio: 1 }}
      >
        <Image source={{ uri: `https://picsum.photos/id/${id}/240/240` }} style={{ flex: 1, opacity: picked.includes(id) ? 0.6 : 1 }} />
        {picked.includes(id) ? (
          <View style={{ position: 'absolute', right: 6, bottom: 6, backgroundColor: '#fff', borderRadius: 12 }}>
            <Icon name="checkCircle" color="primary" />
          </View>
        ) : null}
      </Pressable>
    ))}
  </View>
</Box>

An inbox with a large title​

Loading…
<Header title="Inbox" subtitle="3 unread" size="large" />

A chat header with an avatar​

subtitle adds a line under the title, and leading replaces the back button with anything, such as an avatar in a chat.

Loading…
<Header
  title="Leo Martin"
  subtitle="Online"
  leading={<Avatar size="sm" name="Leo Martin" src="https://picsum.photos/id/1005/160/160" />}
  actions={
    <HStack gap="xs">
      <Button size="icon" variant="ghost" accessibilityLabel="Call">
        <Icon name="phone" />
      </Button>
      <Button size="icon" variant="ghost" accessibilityLabel="Video call">
        <Icon name="video" />
      </Button>
    </HStack>
  }
/>

A new post, in a modal​

In a sheet or a full-screen modal, put Cancel in leading and the confirming action at the end, as iOS does.

Loading…
<VStack gap="md" style={{ maxWidth: 420, width: '100%' }}>
  <Header
    title="New post"
    leading={<Button variant="ghost" size="sm">Cancel</Button>}
    actions={<Button size="sm" disabled={!text.trim()}>Post</Button>}
  />
  <TextArea label="What's on your mind?" value={text} onValueChange={setText} maxLength={280} showCount />
</VStack>

In real apps​

Patine Pro screens built with it. Each opens on that screen, live, in the screens gallery.

Designs​

iOS centers the title and writes the back label beside the chevron; Material puts the title at the start beside an arrow; Patine and the web are compact bars with a hairline under them.

Patine
iOS
Material
Web

Guidelines​

Do

Keep one or two actions. More go in a menu behind a ⋯ button.

Don’t

Don't fill the bar with buttons. The title gets squeezed and the targets shrink.

Do

Name the screen you go back to. On iOS, the back label says where it leads.

Don’t

Don't write long titles. They truncate in a 44pt bar; use the large size for a long one.

Safe area​

Header doesn't add the status bar inset, so it works inside any navigator. Pad it yourself, e.g. style={{ paddingTop: insets.top }}, or render it inside your navigator's own header slot.

Accessibility​

Behaviour
RoleThe title is a heading; the back button is a button named by backLabel ("Back" by default).
AnnouncedThe actions you pass keep their own states.
Keyboard (web)The back button and actions take Tab focus with a focus ring.
Touch targetThe back button has a 44pt touch target.
Reduce motionNothing moves.

API​

Header​

Header also takes View props.

PropTypeDefaultDescription
titlestring—The screen's title.
subtitlestring—A line under the title.
onBack() => void—Shows a back button that calls this.
backLabelstring'Back'The back button's text on iOS and its name for screen readers.
leadingReactNode—Replaces the back button, e.g. a close button.
actionsReactNode—Buttons at the end.
size'default' | 'large''default''large' puts a big title under the bar.
styles{ title?: StyleProp<TextStyle> }—Style slots: title is the title's text.
themeDeepPartial<Theme>—Theme override.
design'brand' | 'ios' | 'material' | 'web' | 'native'from PatineProviderThe look to follow: brand, iOS, Material or web, or 'native' for the platform's own.

Right to left and custom styles work the same on every component: see Internationalization and right to left and Styling.

For AI​

Give this page to an assistant as Markdown, with Copy page at the top, or the whole API in llms-full.txt.

With the Patine MCP server, it asks for get_component_docs({ name: "Header" })