UIPackage React Native
Search

Separator

Hairline divider (View) in horizontal or vertical orientation. Decorative by default and hidden from assistive tech. Requires the init tokens and cn() helper.

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 separator

Source files

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

components/ui/separator/Separator.tsx
import * as React from 'react'
import { View, type ViewProps } from 'react-native'
import { cn } from '@/lib/utils'

export interface SeparatorProps extends ViewProps {
  className?: string
  orientation?: 'horizontal' | 'vertical'
  /** Decorative separators are hidden from assistive tech. Set false only
   *  when the split itself carries meaning, and pass an accessibilityLabel. */
  decorative?: boolean
}

const Separator = React.forwardRef<React.ComponentRef<typeof View>, SeparatorProps>(
  ({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => {
    return (
      <View
        ref={ref}
        aria-hidden={decorative || undefined}
        className={cn('bg-border shrink-0', orientation === 'horizontal' ? 'h-px w-full' : 'h-full w-px', className)}
        {...props}
      />
    )
  },
)
Separator.displayName = 'Separator'

export { Separator }
components/ui/separator/index.ts
export { Separator, type SeparatorProps } from './Separator'
Browse layout and navigation