UIPackage React Native
Search

Label

Native label text and optional pressable label root, backed by RN 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 label

Source files

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

components/ui/label/Label.tsx
import * as React from 'react'
import { Platform } from 'react-native'
import * as LabelPrimitive from '@rn-primitives/label'
import { cssInterop } from 'react-native-css-interop'
import { cn } from '@/lib/utils'

cssInterop(LabelPrimitive.Root, { className: 'style' })
cssInterop(LabelPrimitive.Text, { className: 'style' })

export type LabelProps = LabelPrimitive.TextProps & { className?: string }

export const Label = React.forwardRef<LabelPrimitive.TextRef, LabelProps>(({ className, ...props }, ref) => (
  <LabelPrimitive.Text
    ref={ref}
    className={cn(
      'font-medium text-foreground',
      Platform.OS === 'ios' ? 'text-[17px] leading-[22px]' : 'text-[16px] leading-[24px]',
      className,
    )}
    {...props}
  />
))
Label.displayName = 'Label'

export type LabelRootProps = LabelPrimitive.RootProps & { className?: string }
export const LabelRoot = React.forwardRef<LabelPrimitive.RootRef, LabelRootProps>(({ className, ...props }, ref) => (
  <LabelPrimitive.Root ref={ref} className={cn('min-h-[48px] min-w-[48px] justify-center', className)} {...props} />
))
LabelRoot.displayName = 'LabelRoot'
components/ui/label/index.ts
export * from './Label'

Dependencies

npm packages

  • @rn-primitives/label
  • react-native-css-interop
Browse content and media