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 toggleSource files
Expand a file to read the source the installer copies into your app.
components/ui/toggle/Toggle.tsx
import * as React from 'react'
import { cssInterop } from 'react-native-css-interop'
import * as Primitive from '@rn-primitives/toggle'
import { renderTextChildren } from '@/lib/label-children'
import { cn } from '@/lib/utils'
export type ToggleProps = Omit<Primitive.RootProps, 'children'> & { children?: React.ReactNode; className?: string }
export const Toggle = React.forwardRef<Primitive.RootRef, ToggleProps>(({ children, className, ...props }, ref) => (
<Primitive.Root
{...props}
ref={ref}
className={cn(
'min-h-[48px] min-w-[48px] flex-row items-center justify-center gap-[8px] rounded-md border border-border px-[16px] py-[12px]',
props.pressed && 'bg-secondary',
props.disabled && 'opacity-50',
className,
)}
>
{renderTextChildren(children, 'font-medium')}
</Primitive.Root>
))
Toggle.displayName = 'Toggle'
// The published headless components forward className outside the NativeWind JSX transform.
cssInterop(Primitive.Root, { className: 'style' })
components/ui/toggle/index.ts
export * from './Toggle'
Dependencies
Registry items
npm packages
react-native-css-interop@rn-primitives/toggle