suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

suiss/ui · 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 component from suiss/ui for React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

React Native
Header demo in React Native, light modeHeader demo in React Native, dark mode
import { Button } from "@/components/ui/button"
import {
  Header,
  HeaderActions,
  HeaderBack,
  HeaderTitle,
} from "@/components/ui/header"
import { Text } from "@/components/ui/text"

export default function HeaderDemo() {
  return (
    <Header className="-mx-4 -mt-4">
      <HeaderBack>Settings</HeaderBack>
      <HeaderTitle>Profile</HeaderTitle>
      <HeaderActions>
        <Button variant="plain" size="sm">
import { Button } from "@/components/ui/button"
import {
  Header,
  HeaderActions,
  HeaderBack,
  HeaderTitle,
} from "@/components/ui/header"
import { Text } from "@/components/ui/text"

export default function HeaderDemo() {
  return (
    <Header style={{ marginHorizontal: -16, marginTop: -16 }}>
      <HeaderBack>Settings</HeaderBack>
      <HeaderTitle>Profile</HeaderTitle>
      <HeaderActions>
        <Button variant="plain" size="sm">
import SwiftUI

struct HeaderExample: View {
  var body: some View {
    Header {
      HeaderTitle("Profile")
    } leading: {
      HeaderBack("Settings")
    } trailing: {
      HeaderActions {
        Button {} label: {
          Text("Edit").fontWeight(.semibold)
        }
        .buttonStyle(.variant(.plain, size: .sm))
      }
    }
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.layout
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonSize
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Header
import com.esuiss.ui.components.HeaderActions
import com.esuiss.ui.components.HeaderBack
import com.esuiss.ui.components.HeaderTitle
import com.esuiss.ui.components.Text

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.

Installation

$ pnpm dlx shadcn@latest add @esuiss/header

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add header
$ pnpm dlx shadcn@latest add @esuiss/header

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add header --platform swift
$ pnpm dlx shadcn@latest add @esuiss/header

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add header --platform kotlin

The CLI also adds what it builds on: Icon, Text. It also adds the animated view components/ui/animated-view.tsx.

  1. Install the following 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 animated view into components/ui/animated-view.tsx:

uniwind/components/ui/animated-view.tsx
import { Pressable } from "react-native"
import Animated from "react-native-reanimated"

const AnimatedPressable = Animated.createAnimatedComponent(Pressable)

type AnimatedViewProps =
  | (React.ComponentProps<typeof Animated.View> &
      React.RefAttributes<React.ComponentRef<typeof Animated.View>> & {
        as?: "View"
      })
  | (React.ComponentProps<typeof AnimatedPressable> &
      React.RefAttributes<React.ComponentRef<typeof AnimatedPressable>> & {
        as: "Pressable"
      })

function AnimatedView(props: AnimatedViewProps) {
  1. Copy and paste the following code 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 setup.
  1. Install the following 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 animated view into components/ui/animated-view.tsx:

nativewind/components/ui/animated-view.tsx
import { Pressable } from "react-native"
import Animated from "react-native-reanimated"

const AnimatedPressable = Animated.createAnimatedComponent(Pressable)

type AnimatedViewProps =
  | (React.ComponentProps<typeof Animated.View> &
      React.RefAttributes<React.ComponentRef<typeof Animated.View>> & {
        as?: "View"
      })
  | (React.ComponentProps<typeof AnimatedPressable> &
      React.RefAttributes<React.ComponentRef<typeof AnimatedPressable>> & {
        as: "Pressable"
      })

function AnimatedView(props: AnimatedViewProps) {
  1. Copy and paste the following code into components/ui/header.tsx:
nativewind/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 setup.
  1. Install the following dependencies:
npx expo install phosphor-react-native react-native-reanimated react-native-svg react-native-worklets
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the animated view into components/ui/animated-view.tsx:

stylesheet/components/ui/animated-view.tsx
import { Pressable } from "react-native"
import Animated from "react-native-reanimated"

const AnimatedPressable = Animated.createAnimatedComponent(Pressable)

type AnimatedViewProps =
  | (React.ComponentProps<typeof Animated.View> &
      React.RefAttributes<React.ComponentRef<typeof Animated.View>> & {
        as?: "View"
      })
  | (React.ComponentProps<typeof AnimatedPressable> &
      React.RefAttributes<React.ComponentRef<typeof AnimatedPressable>> & {
        as: "Pressable"
      })

function AnimatedView(props: AnimatedViewProps) {
  1. Copy and paste the following code into components/ui/header.tsx:
stylesheet/components/ui/header.tsx
import { CaretLeftIcon } from "phosphor-react-native"
import * as React from "react"
import {
  I18nManager,
  Pressable,
  type ScrollViewProps,
  type StyleProp,
  StyleSheet,
  type TextStyle,
  View,
  type ViewProps,
  type ViewStyle,
} from "react-native"
import Animated, {
  interpolate,
  type SharedValue,
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Add the Swift package to your app:

Package.swift
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
  1. Copy the theme files every view uses:
swift/Theme/Theme.swift
import CoreText
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source and every file it uses:
swift/Components/Header.swift
import PhosphorSwift
import SwiftUI

extension EnvironmentValues {
  @Entry var headerProgress: CGFloat?
  @Entry var headerReport: ((CGFloat) -> Void)?
}

enum HeaderMath {
  static func progress(minY: CGFloat, height: CGFloat) -> CGFloat {
    guard height > 0 else { return 0 }
    return min(max(-minY / height, 0), 1)
  }
}

public struct Header<Title: View, Leading: View, Trailing: View>: View {
swift/Components/Button.swift
import SwiftUI

public struct VariantButtonStyle: ButtonStyle {
  public enum Variant: CaseIterable, Sendable {
    case `default`, outline, secondary, tinted, ghost, plain, destructive, link
  }

  public enum Size: CaseIterable, Sendable {
    case `default`, xs, sm, lg, xl, form, icon, iconXs, iconSm, iconLg, iconXl

    var height: CGFloat {
      switch self {
      case .xs, .iconXs: Metrics.Height.buttonXs
      case .sm, .iconSm: Metrics.Height.buttonSm
      case .default, .icon: Metrics.Height.button
      case .lg, .iconLg: Metrics.Height.buttonLg
swift/Components/ButtonGroup.swift
import SwiftUI

extension EnvironmentValues {
  @Entry var buttonGroup: Axis? = nil
  @Entry var buttonGroupSize: CGSize = .zero
}

enum ButtonGroupSpace: Hashable {
  case group
}

struct ButtonGroupFrame {
  let bounds: Anchor<CGRect>
  let outlined: Bool
}
swift/Components/Checkbox.swift
import PhosphorSwift
import SwiftUI

extension Shadow {
  static let control = Shadow(color: .black.opacity(0.08), radius: 0.5, y: 0.5)
  static let thumb = Shadow(color: .black.opacity(0.12), radius: 1.5, y: 1)
}

struct SelectionIndicator<Mark: View>: View {
  let checked: Bool
  let pressed: Bool
  let cornerRadius: CGFloat
  let mark: Mark

  @Environment(\.isEnabled) private var isEnabled
  @Environment(\.isInvalid) private var invalid
swift/Components/Field.swift
import SwiftUI

extension EnvironmentValues {
  @Entry public var isInvalid = false
  @Entry var fieldInset = false
  @Entry var fieldSize = FieldSize.default
  @Entry var fieldGroupInset = false
  @Entry var fieldSetInset = false
}

extension View {
  public func invalid(_ isInvalid: Bool = true) -> some View {
    environment(\.isInvalid, isInvalid)
  }
}
swift/Components/Haptics.swift
import SwiftUI

extension EnvironmentValues {
  @Entry public var hapticsEnabled = true
}

extension View {
  public func haptics(_ enabled: Bool) -> some View {
    environment(\.hapticsEnabled, enabled)
  }

  func hapticFeedback<Trigger: Equatable>(_ feedback: SensoryFeedback, trigger: Trigger) -> some View {
    modifier(HapticFeedbackModifier(feedback: feedback, trigger: trigger) { _, _ in true })
  }

  func hapticFeedback<Trigger: Equatable>(
swift/Components/KeyboardScrollView.swift
import SwiftUI
import UIKit

public struct KeyboardScrollView<Content: View>: View {
  let showsIndicators: Bool
  let content: Content

  public init(showsIndicators: Bool = true, @ViewBuilder content: () -> Content) {
    self.showsIndicators = showsIndicators
    self.content = content()
  }

  public var body: some View {
    ScrollView(.vertical, showsIndicators: showsIndicators) {
      content
        .frame(maxWidth: .infinity, alignment: .topLeading)
swift/Components/Screen.swift
import SwiftUI

extension EnvironmentValues {
  @Entry var screenBackground: Color = EsuissColor.background
}

public struct Screen<Content: View>: View {
  public enum Background: CaseIterable, Sendable {
    case background, muted

    var color: Color {
      switch self {
      case .background: EsuissColor.background
      case .muted: EsuissColor.muted
      }
    }
swift/Components/Separator.swift
import SwiftUI

public struct Separator: View {
  let orientation: Axis

  public init(_ orientation: Axis = .horizontal) {
    self.orientation = orientation
  }

  public var body: some View {
    Rectangle()
      .fill(EsuissColor.border)
      .frame(width: orientation == .vertical ? 1 : nil, height: orientation == .horizontal ? 1 : nil)
      .frame(maxWidth: orientation == .horizontal ? .infinity : nil, maxHeight: orientation == .vertical ? .infinity : nil)
      .accessibilityHidden(true)
  }
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
    implementation("com.adamglin:phosphor-icon-android:1.0.0")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
  1. Copy the source and every file it uses:
kotlin/components/Header.kt
package com.esuiss.ui.components

import androidx.compose.animation.core.animate
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
kotlin/components/Button.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
kotlin/components/ButtonGroup.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/Icon.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Icon(
    imageVector: ImageVector,
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { View } from "react-native"
import { Button } from "@/components/ui/button"
import { Header, HeaderTitle, HeaderLargeTitle, HeaderBack, HeaderActions, HeaderScrollView } from "@/components/ui/header"
import { Text } from "@/components/ui/text"
<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>
<View style={{ marginHorizontal: -16, marginTop: -16 }}>
  <Header>
    <HeaderBack>Settings</HeaderBack>
    <HeaderTitle>Profile</HeaderTitle>
    <HeaderActions>
      <Button variant="plain" size="sm">
        <Text style={{ fontWeight: "600" }}>Edit</Text>
      </Button>
    </HeaderActions>
  </Header>
</View>
import SwiftUI

struct HeaderExample: View {
  var body: some View {
    Header {
      HeaderTitle("Profile")
    } leading: {
      HeaderBack("Settings")
    } trailing: {
      HeaderActions {
        Button {} label: {
          Text("Edit").fontWeight(.semibold)
        }
        .buttonStyle(.variant(.plain, size: .sm))
      }
    }
    .headerStoryBleed()
  }
}

extension View {
  func headerStoryBleed() -> some View {
    padding(.horizontal, -16).padding(.top, -16)
  }
}
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.layout
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonSize
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Header
import com.esuiss.ui.components.HeaderActions
import com.esuiss.ui.components.HeaderBack
import com.esuiss.ui.components.HeaderTitle
import com.esuiss.ui.components.Text

fun Modifier.headerBleed(): Modifier = layout { measurable, constraints ->
    val inset = 16.dp.roundToPx()
    val width = constraints.maxWidth + inset * 2
    val placeable = measurable.measure(constraints.copy(minWidth = width, maxWidth = width))
    layout(constraints.maxWidth, (placeable.height - inset).coerceAtLeast(0)) {
        placeable.place(-inset, -inset)
    }
}

@Composable
fun HeaderPlainAction(text: String) {
    Button(onClick = {}, variant = ButtonVariant.Plain, size = ButtonSize.Sm) {
        Text(text, style = TextStyle(fontWeight = FontWeight.SemiBold))
    }
}

@Composable
fun HeaderDefault() {
    Column(Modifier.headerBleed()) {
        Header {
            HeaderBack(onClick = {}, text = "Settings")
            HeaderTitle("Profile")
            HeaderActions { HeaderPlainAction("Edit") }
        }
    }
}

Examples

Large title

A large title that collapses into the bar on scroll.

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.

React Native
Header large title in React Native, light modeHeader large title in React Native, dark mode
import { MagnifyingGlassIcon, PlusIcon } from "phosphor-react-native"
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import {
  Header,
  HeaderActions,
  HeaderBack,
  HeaderLargeTitle,
  HeaderScrollView,
  HeaderTitle,
  useHeaderScroll,
} from "@/components/ui/header"
import { Icon } from "@/components/ui/icon"
import { Text } from "@/components/ui/text"

const messages = [

This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.

import PhosphorSwift
import SwiftUI

let headerMessages = [
  "Lunch on Friday?",
  "The draft is ready for review",
  "Photos from the trip",
  "Invoice for September",
  "Your order has shipped",
  "Team sync moved to 3 PM",
  "Weekend plans",
  "Book club picks",
  "Flight confirmation",
  "New comment on your post",
  "Reminder: dentist at 10",
  "Quarterly report",
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.MagnifyingGlass
import com.adamglin.phosphoricons.regular.Plus
import com.esuiss.ui.components.Button

Large title with subtitle

A large title with a subtitle.

React Native
Header large title with subtitle in React Native, light modeHeader large title with subtitle in React Native, dark mode
import { MagnifyingGlassIcon, PlusIcon } from "phosphor-react-native"
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import {
  Header,
  HeaderActions,
  HeaderBack,
  HeaderLargeTitle,
  HeaderScrollView,
  HeaderTitle,
  useHeaderScroll,
} from "@/components/ui/header"
import { Icon } from "@/components/ui/icon"
import { Text } from "@/components/ui/text"

const messages = [

This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.

import PhosphorSwift
import SwiftUI

struct HeaderLargeTitleWithSubtitleExample: View {
  var body: some View {
    HeaderLargeTitleDemo(subtitle: "3 unread")
  }
}

let headerMessages = [
  "Lunch on Friday?",
  "The draft is ready for review",
  "Photos from the trip",
  "Invoice for September",
  "Your order has shipped",
  "Team sync moved to 3 PM",
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.MagnifyingGlass
import com.adamglin.phosphoricons.regular.Plus
import com.esuiss.ui.components.Button

Compact with scroll

A compact title whose hairline appears on scroll.

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.

React Native
Header compact with scroll in React Native, light modeHeader compact with scroll in React Native, dark mode
import { DotsThreeIcon } from "phosphor-react-native"
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import {
  Header,
  HeaderActions,
  HeaderBack,
  HeaderScrollView,
  HeaderTitle,
  useHeaderScroll,
} from "@/components/ui/header"
import { Icon } from "@/components/ui/icon"
import { Text } from "@/components/ui/text"

const messages = [
  "Lunch on Friday?",

This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.

import PhosphorSwift
import SwiftUI

struct HeaderCompactWithScrollExample: View {
  var body: some View {
    HeaderScrollView {
      HeaderMessageRows()
    } header: {
      Header {
        HeaderTitle("Inbox", subtitle: "15 messages")
      } leading: {
        HeaderBack()
      } trailing: {
        HeaderActions {
          HeaderIconButton(icon: Ph.dotsThree.bold, label: "More")
        }
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Bold
import com.adamglin.phosphoricons.bold.DotsThree
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonSize
import com.esuiss.ui.components.ButtonVariant

Subtitle

A two-line title with a subtitle.

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

React Native
Header subtitle in React Native, light modeHeader subtitle in React Native, dark mode
import { MagnifyingGlassIcon, PlusIcon } from "phosphor-react-native"
import { Button } from "@/components/ui/button"
import {
  Header,
  HeaderActions,
  HeaderBack,
  HeaderTitle,
} from "@/components/ui/header"
import { Icon } from "@/components/ui/icon"

export default function HeaderSubtitle() {
  return (
    <Header className="-mx-4 -mt-4">
      <HeaderBack />
      <HeaderTitle subtitle="Last seen today">Alex Morgan</HeaderTitle>
      <HeaderActions>
import { MagnifyingGlassIcon, PlusIcon } from "phosphor-react-native"
import { Button } from "@/components/ui/button"
import {
  Header,
  HeaderActions,
  HeaderBack,
  HeaderTitle,
} from "@/components/ui/header"
import { Icon } from "@/components/ui/icon"

export default function HeaderSubtitle() {
  return (
    <Header style={{ marginHorizontal: -16, marginTop: -16 }}>
      <HeaderBack />
      <HeaderTitle subtitle="Last seen today">Alex Morgan</HeaderTitle>
      <HeaderActions>
import PhosphorSwift
import SwiftUI

struct HeaderSubtitleExample: View {
  var body: some View {
    Header {
      HeaderTitle("Alex Morgan", subtitle: "Last seen today")
    } leading: {
      HeaderBack()
    } trailing: {
      HeaderTrailingActions()
    }
    .headerStoryBleed()
  }
}
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.layout
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.MagnifyingGlass
import com.adamglin.phosphoricons.regular.Plus
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonSize
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Header
import com.esuiss.ui.components.HeaderActions
import com.esuiss.ui.components.HeaderBack
import com.esuiss.ui.components.HeaderTitle

Leading actions

Actions on both sides of the title.

Set side="leading" on HeaderActions to place a group on the start side.

React Native
Header leading actions in React Native, light modeHeader leading actions in React Native, dark mode
import { ListIcon } from "phosphor-react-native"
import { Button } from "@/components/ui/button"
import { Header, HeaderActions, HeaderTitle } from "@/components/ui/header"
import { Icon } from "@/components/ui/icon"
import { Text } from "@/components/ui/text"

export default function HeaderLeadingActions() {
  return (
    <Header className="-mx-4 -mt-4">
      <HeaderActions side="leading">
        <Button variant="ghost" size="icon" accessibilityLabel="Menu">
          <Icon as={ListIcon} className="size-5" />
        </Button>
      </HeaderActions>
      <HeaderTitle>Library</HeaderTitle>
      <HeaderActions>
import { ListIcon } from "phosphor-react-native"
import { Button } from "@/components/ui/button"
import { Header, HeaderActions, HeaderTitle } from "@/components/ui/header"
import { Icon } from "@/components/ui/icon"
import { Text } from "@/components/ui/text"

export default function HeaderLeadingActions() {
  return (
    <Header style={{ marginHorizontal: -16, marginTop: -16 }}>
      <HeaderActions side="leading">
        <Button variant="ghost" size="icon" accessibilityLabel="Menu">
          <Icon as={ListIcon} size={20} />
        </Button>
      </HeaderActions>
      <HeaderTitle>Library</HeaderTitle>
      <HeaderActions>
import PhosphorSwift
import SwiftUI

struct HeaderLeadingActionsExample: View {
  var body: some View {
    Header {
      HeaderTitle("Library")
    } leading: {
      HeaderActions {
        HeaderIconButton(icon: Ph.list.regular, label: "Menu")
      }
    } trailing: {
      HeaderActions {
        Button {} label: {
          Text("Done").fontWeight(.semibold)
        }
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.layout
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.List
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonSize
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Header
import com.esuiss.ui.components.HeaderActions
import com.esuiss.ui.components.HeaderActionsSide

Back only

A long back label that truncates.

React Native
Header back only in React Native, light modeHeader back only in React Native, dark mode
import { Header, HeaderBack, HeaderTitle } from "@/components/ui/header"

export default function HeaderBackOnly() {
  return (
    <Header className="-mx-4 -mt-4">
      <HeaderBack>A very long previous screen title</HeaderBack>
      <HeaderTitle>Details</HeaderTitle>
    </Header>
  )
}
import { Header, HeaderBack, HeaderTitle } from "@/components/ui/header"

export default function HeaderBackOnly() {
  return (
    <Header style={{ marginHorizontal: -16, marginTop: -16 }}>
      <HeaderBack>A very long previous screen title</HeaderBack>
      <HeaderTitle>Details</HeaderTitle>
    </Header>
  )
}
import SwiftUI

struct HeaderBackOnlyExample: View {
  var body: some View {
    Header {
      HeaderTitle("Details")
    } leading: {
      HeaderBack("A very long previous screen title")
    }
    .headerStoryBleed()
  }
}

extension View {
  func headerStoryBleed() -> some View {
    padding(.horizontal, -16).padding(.top, -16)
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.layout
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Header
import com.esuiss.ui.components.HeaderBack
import com.esuiss.ui.components.HeaderTitle

fun Modifier.headerBleed(): Modifier = layout { measurable, constraints ->
    val inset = 16.dp.roundToPx()
    val width = constraints.maxWidth + inset * 2
    val placeable = measurable.measure(constraints.copy(minWidth = width, maxWidth = width))
    layout(constraints.maxWidth, (placeable.height - inset).coerceAtLeast(0)) {
        placeable.place(-inset, -inset)
    }

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.

API Reference

Header

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

PropTypeDefault
scrollHeaderScroll-

Also accepts the props of ViewProps.

scroll takes the scroll state from useHeaderScroll(). Colors follow light and dark mode with the system appearance.

HeaderTitle

Centered title with optional subtitle.

PropTypeDefault
subtitleReact.ReactNode-

Also accepts the props of ViewProps.

HeaderLargeTitle

Large title at the top of the scroll content.

PropTypeDefault
subtitleReact.ReactNode-

Also accepts the props of ViewProps.

In right-to-left layouts the large title scales from the correct edge.

HeaderBack

Back button with a caret and optional label.

PropTypeDefault
childrenReact.ReactNode-

Also accepts the props of React.ComponentProps<typeof Pressable>.

Pass a text label such as the previous screen's name as children, and wire onPress to your navigation. The button dims to opacity-80 while pressed, and the caret rotates in right-to-left layouts.

HeaderActions

Row of actions for either side.

PropTypeDefault
side"leading" | "trailing""trailing"

Also accepts the props of ViewProps.

Group icon buttons in HeaderActions.

HeaderScrollView

Scroll view that drives the header animations.

PropTypeDefault
scrollHeaderScrollRequired

Also accepts the props of ScrollViewProps.

Pass the same scroll state from useHeaderScroll() that the Header gets.

Header

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

ParameterTypeDefault
title() -> Title-
leading() -> Leading-
trailing() -> Trailing-

Overloads: init(title:leading:trailing:), init(title:trailing:), init(title:leading:), init(title:).

HeaderTitle

Centered title with optional subtitle.

ParameterTypeDefault
_ titleLocalizedStringKey-
subtitleLocalizedStringKey?nil
verbatimString-

Overloads: init(_:subtitle:), init(verbatim:subtitle:).

HeaderLargeTitle

Large title at the top of the scroll content.

ParameterTypeDefault
_ titleLocalizedStringKey-
subtitleLocalizedStringKey?nil
verbatimString-

Overloads: init(_:subtitle:), init(verbatim:subtitle:).

HeaderBack

Back button with a caret and optional label.

ParameterTypeDefault
_ labelLocalizedStringKey?nil
action(() -> Void)?nil
verbatimString-

Overloads: init(_:action:), init(verbatim:action:).

HeaderActions

Row of actions for either side.

ParameterTypeDefault
content() -> Content-

HeaderScrollView

Scroll view that drives the header animations.

ParameterTypeDefault
content() -> Content-
header() -> HeaderContent-

HeaderActionsSide

Values: Leading, Trailing.

HeaderState

Takes no parameters.

PropertyType
collapsedFractionFloat
nestedScrollConnectionNestedScrollConnection

rememberHeaderState

Takes no parameters.

Returns HeaderState.

Header

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

ParameterTypeDefault
modifierModifierModifier
stateHeaderStaterememberHeaderState()
content@Composable () -> Unit-

HeaderTitle

Centered title with optional subtitle.

ParameterTypeDefault
textString-
modifierModifierModifier
subtitleString?null

HeaderLargeTitle

Large title at the top of the scroll content.

ParameterTypeDefault
textString-
modifierModifierModifier
subtitleString?null

HeaderBack

Back button with a caret and optional label.

ParameterTypeDefault
onClick() -> Unit-
modifierModifierModifier
textString?"Back"
contentDescriptionStringtext ?: "Back"

HeaderActions

Row of actions for either side.

ParameterTypeDefault
modifierModifierModifier
sideHeaderActionsSide: Leading | TrailingHeaderActionsSide.Trailing
content@Composable RowScope.() -> Unit-
NextHover CardPreviousHaptics

On this page

  1. 01Installation
  2. 02Usage
  3. 03Examples
    • Large title
    • Large title with subtitle
    • Compact with scroll
    • Subtitle
    • Leading actions
    • Back only
  4. 04Accessibility
  5. 05API Reference
    • Header
    • HeaderTitle
    • HeaderLargeTitle
    • HeaderBack
    • HeaderActions
    • HeaderScrollView
    • Header
    • HeaderTitle
    • HeaderLargeTitle
    • HeaderBack
    • HeaderActions
    • HeaderScrollView
    • HeaderActionsSide
    • HeaderState
    • rememberHeaderState
    • Header
    • HeaderTitle
    • HeaderLargeTitle
    • HeaderBack
    • HeaderActions