UIPackage React Native
Search
Menu

Profile Header

Identity row for profile screens: large Avatar with initials fallback, name as header, muted subtitle, and a trailing action slot.

Install

First install? Set up the registry in your app.

npx --yes --package=https://native.uipkge.dev/cli/uipkge-native-0.1.1.tgz uipkge-native add profile-header

Source files

Expand a file to read the source the installer copies into your app.

components/blocks/profile-header/ProfileHeader.tsx
import * as React from 'react'
import { View, type ImageSourcePropType, type ViewProps } from 'react-native'
import { cn } from '@/lib/utils'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Text } from '@/components/ui/text'

export interface ProfileHeaderProps extends ViewProps {
  className?: string
  name: string
  subtitle?: string
  imageSource?: ImageSourcePropType
  /** Trailing slot, usually an Edit button. */
  action?: React.ReactNode
}

/** Two-letter monogram from the first and last words of a display name. */
export function initialsFor(name: string): string {
  const parts = name.trim().split(/\s+/).filter(Boolean)
  if (parts.length === 0) return '?'
  if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase()
  return `${parts[0][0]}${parts[parts.length - 1][0]}`.toUpperCase()
}

/** Identity row for profile and account screens: avatar, name, subtitle. */
function ProfileHeader({ className, name, subtitle, imageSource, action, ...props }: ProfileHeaderProps) {
  return (
    <View className={cn('flex-row items-center gap-3', className)} {...props}>
      <Avatar size="lg">
        <AvatarFallback size="lg">{initialsFor(name)}</AvatarFallback>
        {imageSource ? <AvatarImage source={imageSource} /> : null}
      </Avatar>
      <View className="min-w-0 flex-1 gap-0.5">
        <Text size="lg" className="font-semibold" accessibilityRole="header" numberOfLines={1}>
          {name}
        </Text>
        {subtitle ? (
          <Text variant="muted" size="sm" numberOfLines={1}>
            {subtitle}
          </Text>
        ) : null}
      </View>
      {action}
    </View>
  )
}

export { ProfileHeader }
components/blocks/profile-header/index.ts
export { ProfileHeader, initialsFor, type ProfileHeaderProps } from './ProfileHeader'

Dependencies

Registry items

Browse accounts and messaging