UIPackage React Native
Search

Icon

Lucide icon adapter with themed colors, forwarded SVG props, and decorative defaults.

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 icon

Source files

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

components/ui/icon/Icon.tsx
import * as React from 'react'
import { Platform } from 'react-native'
import type { LucideIcon, LucideProps } from 'lucide-react-native'
import type { Svg } from 'react-native-svg'
import { cssInterop } from 'react-native-css-interop'
import { useThemeColors } from '@/lib/theme'

export interface IconProps extends LucideProps {
  icon: LucideIcon
  className?: string
}

export const Icon = React.forwardRef<React.ComponentRef<typeof Svg>, IconProps>(
  ({ icon: IconComponent, size = 20, color, accessibilityLabel, ...props }, ref) => {
    const colors = useThemeColors()
    // Lucide forwards its SVG ref, but the LucideIcon alias omits that prop.
    const SvgIcon = IconComponent as React.ComponentType<
      LucideProps & React.RefAttributes<React.ComponentRef<typeof Svg>>
    >
    return (
      <SvgIcon
        ref={ref}
        size={size}
        color={color ?? colors.foreground}
        accessible={Platform.OS === 'web' ? undefined : !!accessibilityLabel}
        aria-hidden={!accessibilityLabel}
        accessibilityLabel={Platform.OS === 'web' ? undefined : accessibilityLabel}
        aria-label={accessibilityLabel}
        {...props}
      />
    )
  },
)
Icon.displayName = 'Icon'

cssInterop(Icon, { className: { target: 'style', nativeStyleToProp: { color: true } } })
components/ui/icon/index.ts
export * from './Icon'

Dependencies

npm packages

  • lucide-react-native
  • react-native-svg
  • react-native-css-interop
Browse content and media