Separator
Separator Primitive
Demo
Creates a visual or semantic distinction between content.
Installation
npx @react-native-reusables/cli@latest add separator
Copy/paste the following code to ~/components/ui/separator.tsx
import * as SeparatorPrimitive from '@rn-primitives/separator';import * as React from 'react';import { cn } from '~/lib/utils';
const Separator = React.forwardRef<SeparatorPrimitive.RootRef, SeparatorPrimitive.RootProps>( ({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => ( <SeparatorPrimitive.Root ref={ref} decorative={decorative} orientation={orientation} className={cn( 'shrink-0 bg-border', orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]', className )} {...props} /> ));Separator.displayName = SeparatorPrimitive.Root.displayName;
export { Separator };
Usage
import { View } from 'react-native';import { Separator } from '~/components/ui/separator';import { H4, P, Small } from '~/components/ui/typography';
function Example() { return ( <View className='flex-1 justify-center items-center p-6 gap-12'> <View className='w-full max-w-xs '> <View className='gap-1'> <H4 className='text-sm native:text-base font-medium leading-none'>Radix Primitives</H4> <P className='text-sm native:text-base text-muted-foreground'> An open-source UI component library. </P> </View> <Separator className='my-4' /> <View className='flex flex-row h-5 items-center gap-4 '> <Small className='font-normal'>Blog</Small> <Separator orientation='vertical' /> <Small className='font-normal'>Docs</Small> <Separator orientation='vertical' /> <Small className='font-normal'>Source</Small> </View> </View> </View> );}
Props
Separator
Extends View
props
Prop | Type | Note |
---|---|---|
orientation | ’horizontal’ | ‘vertical’ | Defaults to horizontal (optional) |
decorative | boolean | (optional) |
asChild | boolean | (optional) |