UIPackage React Native
Search

Alert

Composable inline notice with caller-owned title, description, icons, and actions.

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 alert

Source files

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

components/ui/alert/Alert.tsx
import * as React from 'react'
import { View, type ViewProps } from 'react-native'
import { Text, type TextProps } from '@/components/ui/text'
import { cn } from '@/lib/utils'

export interface AlertProps extends ViewProps {
  className?: string
  variant?: 'default' | 'destructive'
}

export const Alert = React.forwardRef<React.ComponentRef<typeof View>, AlertProps>(
  ({ className, variant = 'default', accessibilityRole = 'alert', ...props }, ref) => (
    <View
      ref={ref}
      accessibilityRole={accessibilityRole}
      className={cn(
        'gap-[8px] rounded-lg border bg-card p-4',
        variant === 'destructive' ? 'border-destructive' : 'border-border',
        className,
      )}
      {...props}
    />
  ),
)
Alert.displayName = 'Alert'

export const AlertTitle = React.forwardRef<React.ComponentRef<typeof Text>, TextProps>(
  ({ className, accessibilityRole = 'header', ...props }, ref) => (
    <Text ref={ref} accessibilityRole={accessibilityRole} className={cn('font-semibold', className)} {...props} />
  ),
)
AlertTitle.displayName = 'AlertTitle'

export const AlertDescription = React.forwardRef<React.ComponentRef<typeof Text>, TextProps>((props, ref) => (
  <Text ref={ref} size="sm" variant="muted" {...props} />
))
AlertDescription.displayName = 'AlertDescription'

export const AlertActions = React.forwardRef<React.ComponentRef<typeof View>, ViewProps & { className?: string }>(
  ({ className, ...props }, ref) => (
    <View ref={ref} className={cn('flex-row flex-wrap items-center gap-[8px]', className)} {...props} />
  ),
)
AlertActions.displayName = 'AlertActions'
components/ui/alert/index.ts
export * from './Alert'

Dependencies

Registry items

Browse overlays and feedback