Popover
nativeui/popoverFreeComponent
A popover component for React Native applications.
Live preview
live · rendered by the registry
Rendered by nativeui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://nativeui.ribbi.ch/r/popover.jsonSource
1import * as React from "react"2import {3 View,4 Text,5 Pressable,6 Modal,7 TouchableWithoutFeedback,8 Platform,9 Animated,10} from "react-native"11import { cn } from "@/lib/utils"1213interface PopoverProps {14 children: React.ReactNode15 className?: string16}1718interface PopoverTriggerProps {19 children: React.ReactNode20 className?: string21 disabled?: boolean22 asChild?: boolean23}2425interface PopoverAnchorProps {26 children: React.ReactNode27 className?: string28}2930interface PopoverContentProps {31 children: React.ReactNode32 className?: string33 align?: "start" | "center" | "end"34 side?: "top" | "right" | "bottom" | "left"35 sideOffset?: number36}3738const PopoverContext = React.createContext<{39 open: boolean40 setOpen: React.Dispatch<React.SetStateAction<boolean>>41 triggerRef: React.RefObject<View>42 triggerLayout: { x: number; y: number; width: number; height: number } | null43 setTriggerLayout: React.Dispatch<React.SetStateAction<{ x: number; y: number; width: number; height: number } | null>>44 contentLayout: { width: number; height: number } | null45 setContentLayout: React.Dispatch<React.SetStateAction<{ width: number; height: number } | null>>46 isAnimating: boolean47 setIsAnimating: React.Dispatch<React.SetStateAction<boolean>>48}>({49 open: false,50 setOpen: () => { },51 triggerRef: { current: null },52 triggerLayout: null,53 setTriggerLayout: () => { },54 contentLayout: null,55 setContentLayout: () => { },56 isAnimating: false,57 setIsAnimating: () => { },58})5960const Popover = React.forwardRef<View, PopoverProps>(61 ({ children, className, ...props }, ref) => {62 const [open, setOpen] = React.useState(false)63 const triggerRef = React.useRef<View>(null)64 const [triggerLayout, setTriggerLayout] = React.useState<{ x: number; y: number; width: number; height: number } | null>(null)65 const [contentLayout, setContentLayout] = React.useState<{ width: number; height: number } | null>(null)66 const [isAnimating, setIsAnimating] = React.useState(false)6768 return (69 <PopoverContext.Provider70 value={{71 open,72 setOpen,73 triggerRef,74 triggerLayout,75 setTriggerLayout,76 contentLayout,77 setContentLayout,78 isAnimating,79 setIsAnimating,80 }}81 >82 <View ref={ref} className={cn("", className)} {...props}>83 {children}84 </View>85 </PopoverContext.Provider>86 )87 }88)8990Popover.displayName = "Popover"9192// … truncated
What it pulls in
npm packages
Files it writes
More from nativeui
All 29 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | nativeui | Components | Free | 2 deps | |
| Alertalert | nativeui | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | nativeui | Components | Free | 1 dep | |
| Avataravatar | nativeui | Components | Free | 1 dep | |
| Badgebadge | nativeui | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | nativeui | Components | Free | 2 deps | |
| Buttonbutton | nativeui | Components | Free | 2 deps | |
| Calendarcalendar | nativeui | Components | Free | 4 deps |
