UIPackage React Native
Search

Empty State

Centered no-content section with an optional icon medallion, headline, explanation, and one recovery action. Built from Text and Button primitives.

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 empty-state

Source files

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

components/blocks/empty-state/EmptyState.tsx
import * as React from 'react'
import { View, type ViewProps } from 'react-native'
import { cn } from '@/lib/utils'
import { Button } from '@/components/ui/button'
import { Text } from '@/components/ui/text'

export interface EmptyStateProps extends ViewProps {
  className?: string
  /** Decorative icon rendered inside a muted circle. */
  icon?: React.ReactNode
  title: string
  description?: string
  /** The action button renders only when both `actionLabel` and `onAction` are supplied. */
  actionLabel?: string
  onAction?: () => void
}

/** Centered no-content section that explains what is missing and offers
 *  the next action instead of a dead end. */
function EmptyState({ className, icon, title, description, actionLabel, onAction, ...props }: EmptyStateProps) {
  return (
    <View className={cn('items-center gap-3 px-6 py-10', className)} {...props}>
      {icon ? (
        <View
          aria-hidden
          className="bg-muted h-14 w-14 items-center justify-center rounded-full"
        >
          {icon}
        </View>
      ) : null}
      <View className="items-center gap-1">
        <Text size="lg" className="text-center font-semibold" accessibilityRole="header">
          {title}
        </Text>
        {description ? (
          <Text variant="muted" size="sm" className="text-center">
            {description}
          </Text>
        ) : null}
      </View>
      {actionLabel && onAction ? (
        <Button accessibilityLabel={actionLabel} onPress={onAction} className="mt-2">
          {actionLabel}
        </Button>
      ) : null}
    </View>
  )
}

export { EmptyState }
components/blocks/empty-state/index.ts
export { EmptyState, type EmptyStateProps } from './EmptyState'

Dependencies

Registry items

Browse work and productivity