UIPackage React Native
Search

Fab

Primary floating-action control with icon-only and extended-label forms; screens own placement.

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 fab

Source files

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

components/ui/fab/Fab.tsx
import * as React from 'react'
import { Pressable } from 'react-native'
import type { LucideIcon } from 'lucide-react-native'
import { Button, type ButtonProps } from '@/components/ui/button'
import { Icon } from '@/components/ui/icon'
import { useThemeColors } from '@/lib/theme'
import { cn } from '@/lib/utils'

export interface FabProps extends Omit<ButtonProps, 'children' | 'size' | 'variant'> {
  icon: LucideIcon
  label?: string
  accessibilityLabel: string
}

/** The screen owns floating placement and the space reserved around navigation. */
export const Fab = React.forwardRef<React.ComponentRef<typeof Pressable>, FabProps>(
  ({ icon, label, className, ...props }, ref) => {
    const colors = useThemeColors()
    return (
      <Button ref={ref} {...props} size={label ? 'lg' : 'icon'} className={cn('self-start rounded-full', className)}>
        <Icon icon={icon} size={24} color={colors.primaryForeground} />
        {label}
      </Button>
    )
  },
)
Fab.displayName = 'Fab'
components/ui/fab/index.ts
export * from './Fab'

Dependencies

Registry items

npm packages

  • lucide-react-native
Browse controls and interactions