Gathering detailed insights and metrics for react-native-ios-popover
Gathering detailed insights and metrics for react-native-ios-popover
Gathering detailed insights and metrics for react-native-ios-popover
Gathering detailed insights and metrics for react-native-ios-popover
react-native-popover-view
A <Popover /> component for react-native iOS, Android, and Web
@gluestack-ui/popover
A universal headless Popover component for React Native, Next.js & React
react-native-modal-selector
A cross-platform (iOS / Android), selector/picker component for React Native that is highly customizable and supports sections.
@react-native-oh-tpl/react-native-popover-view
A <Popover /> component for react-native iOS, Android, and Web
A react-native component to use the native popover in iOS
npm install react-native-ios-popover
Typescript
Module System
Node Version
NPM Version
TypeScript (38.15%)
JavaScript (27.98%)
Swift (19.48%)
Java (5.3%)
Objective-C++ (3.75%)
Objective-C (2.46%)
Ruby (1.82%)
Kotlin (0.98%)
C (0.09%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
42 Stars
234 Commits
2 Forks
2 Watchers
2 Branches
1 Contributors
Updated on Jan 11, 2025
Latest Version
3.0.0
Package Id
react-native-ios-popover@3.0.0
Unpacked Size
173.93 kB
Size
45.96 kB
File Count
96
NPM Version
8.1.0
Node Version
16.13.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A react native wrapper component to use the native iOS popover by wrapping a react native view inside a UIViewController
and presenting it.
PopoverView
Left: Example 1, Example 2, and Right: Example 3, Example 4
PopoverView
Left: Example 5, Example 6, and Right: Example 7, Example 8
Re-write in progress (see TODO for updates). See README-old.md
for the old version of the documentation.
1# 1 install via npm... 2npm install react-native-ios-popover 3 4# 1.2 ...or install via yarn 5yarn add react-native-ios-popover 6 7# 2.1 install dependency via npm... 8npm install react-native-ios-utilities 9 10# 2.2 ...or install dependency via yarn 11# Note: See "Installation: Dependencies" section for more details 12yarn install react-native-ios-utilities 13 14# 3. then run pod install (uses auto-linking) 15cd ios && pod install
If you encounter any errors/bugs while using this library, or want a particular feature implemented, please see the troubleshooting section, or create an issue!
This library depends on react-native-ios-utilities
for some of the native functionality (i.e. it uses it as a peer dependency).
If you want to install and use a specific version of this library, please see the Installation: Versions and Compatibility section for more details.
If you are using any other library that uses react-native-ios-utilities
(e.g. react-native-ios-context-menu
, etc)., then please refer to the version compatibility guide.
The library's peer dependency requirements are enforced using semver (i.e. major.minor.patch
). If you wish to use a specific version of this library, then please install the corresponding version of react-native-ios-utilities
.
📝 Note: As a general rule, the major
version should be the same between the library and the dependency. For example, if you're using react-native-ios-popover@2.3.12
, then you should install react-native-ios-popover@2.x.x
, etc.
Library Version react-native-ios-popover | Dependency Version react-native-ios-utilities |
---|---|
0.x.x | N/A (No External Dependencies) |
1.x.x | 0.x.x |
2.0.x | 2.0.x |
3.0.x | 3.0.x |
This library is written in Swift. If you are having trouble building your app after installing this library, try adding an empty swift file:
ios/project.xcworkspace
projectIf you encounter the following error when running pod install
:
[!] The following Swift pods cannot yet be integrated as static libraries:
The Swift pod `react-native-ios-popover` depends upon `React-Core`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
Then try following these steps:
ios/podfile
configurationtarget 'ProjectName' do
block, find the 'React-Core'
pod, and append the following snippet to the end of the line: , :modular_headers => true
pod 'React-Core', :path => '../node_modules/react-native/', :modular_headers => true
pod install
again.Please check out the examples section or the examples directory for more on how to use it.
1import { PopoverView } from "react-native-ios-popover"; 2 3function PopoverViewExample() { 4 const popoverRef = useRef(); 5 6 return ( 7 <PopoverView 8 ref={popoverRef} 9 renderPopoverContent={() => ( 10 <View style={{padding: 20}}> 11 <Text> 12 {'Popover Content'} 13 </Text> 14 </View> 15 )} 16 > 17 <TouchableOpacity onPress={() => { 18 popoverRef.current.toggleVisibility(); 19 }}> 20 <Text> 21 {'Toggle Popover Visibility'} 22 </Text> 23 </TouchableOpacity> 24 </PopoverView> 25 ); 26};
PopoverView
ComponentPopoverView
Component: PropsProp Name | Description |
---|---|
🔤 Required: renderPopoverContent ⚛️ () => React.ReactElement | The elements to show in the popover. This prop accepts a function that returns an element. The element returned from this function will be shown in the popover. See example 1 section. |
🔤 popoverSize ⚛️ PopoverSizeConfig ✳️ Default: { type: 'INHERIT' } | Controls the size the of the popover. This prop accepts a PopoverSizeConfig object.If you want to set a custom size for the popover, provide a PopoverSizeConfig with the type property set to CUSTOM , along with the desired height and width (e.g. {type: 'CUSTOM', width: 100, height: 100} ).See example 3 section. |
🔤 popoverBackgroundColor ⚛️ string ✳️ Default: transparent | Sets the background color of the popover. See example 4 section. |
🔤 permittedArrowDirections ⚛️ Array<PopoverArrowDirections> | Sets the arrow directions that you allow for the popover. Accept an array of 0 or more string values, i.e. an array of ArrowDirections enum items (e.g. up , down , etc.)Note If you pass in an empty array, then there will be no arrow shown. See example 2 section. |
🔤 lazyPopover ⚛️ boolean ✳️ Default: true | Controls whether or not the popover content is always mounted. If set to true the popover content will only be mounted while the popover is visible.Set this to false to prevent the popover from closing. |
🔤 popoverShouldDismiss ⚛️ boolean ✳️ Default: true | Controls whether or not a tap outside the popover will dismiss it. See example 7 section. |
🔤 popoverCan OverlapSourceViewRect ⚛️ boolean ✳️ Default: false | Controls whether the popover can overlap its source view. If set to false the popover will avoid covering up the source view.See example 3 section. |
PopoverView
Component: EventsEvent Name | Description |
---|---|
🔤 onPopoverDidShow ⚛️ OnPopoverDidShowEvent | Event that gets called after the popover is shown, i.e. this event is invoked after the popover entrance animation is finished. |
🔤 onPopoverDidHide ⚛️ OnPopoverDidHideEvent | Event that gets called after the popover is hidden, i.e. this event is invoked after the popover exit animation is finished. |
🔤 onPopoverWillShow ⚛️ OnPopoverWillShowEvent | Event that gets called before the popover is shown, i.e. this event is immediently invoked when the popover is about to become visible. |
🔤 onPopoverWillHide ⚛️ OnPopoverWillHideEvent | Event that gets called before the popover is hidden, i.e. this event is immediently invoked when the popover is about to become hidden. |
🔤 onPopoverDidHideViaTap ⚛️ OnPopoverDidHideViaTapEvent | Event that gets called before the popover is hidden due to a tap outside the popover's content, i.e. this event is immediently invoked when the popover is about to become hidden. |
🔤 onPopoverWillHideViaTap ⚛️ OnPopoverWillHideViaTapEvent | Event that gets called after the popover is hidden due to a tap outside the popover's content, i.e. this event is invoked after the popover exit animation is finished. |
🔤 onPopoverDidAttemptToDismiss ⚛️ OnPopoverDidAttemptToDismissEvent | This event is invoked when the popoverShouldDismiss prop is set to false , and a tap outside the popover's content is initiated to dismiss the popover. |
PopoverView
Component: FunctionsFunction Name | Description |
---|---|
🔤 setVisibility( visibility: boolean) ⚛️ Promise<void> | A function that you can call to set whether or not the popover is shown or hidden. This function returns a promise that gets resolved when the popover is successfully shown or hidden. This function throws an error if the popover is already hidden or shown. See Example 1 section |
🔤 toggleVisibility ⚛️ Promise<void> | A function that you can call to toggle the popover's visibility. This function returns a promise that gets resolved when the popover is successfully shown or hidden. |
🔤 getVisibility ⚛️ Promise<boolean> | A function to query whether or not the popover is visible. Returrns a promise that resolves to a boolean value. |
PopoverRelatedTypes.ts
PopoverRelatedTypes.ts
PopoverSize
This type is used in the PopoverView
component's popoverSize
prop. Use this type to control the size of the popover.
Value | Description |
---|---|
INHERIT | The default value. Specifies that the popover's size should match the view you return from PopoverView.renderPopoverContent prop. It will automatically resize/scale the popover to fit the screen. |
STRETCH | Specifies that we want the popover to be as big as possible, i.e. the popover should to stretch and fill up the screen. |
CUSTOM | Specifies that a custom size is to be use for popover via the popoverSize object. |
ArrowDirections
This type is used to for the PopoverView
component's permittedArrowDirections
prop. This type corresponds to the UIPopoverArrowDirection
swift struct, check out the apple docs for more info.
Value | Description |
---|---|
up | An arrow that points upward. The popover will appear at the bottom with the arrow pointing up. |
down | An arrow that points downward. The popover will appear at the top with the arrow pointing down. |
left | An arrow that points toward the left. The popover will appear at the right with the arrow pointing left. |
right | An arrow that points toward the right. The popover will appear at the left with the arrow pointing right. |
any | An arrow that points in any direction. |
unknown | The status of the arrow is currently unknown. |
Check out the examples directory. The example app contains a bunch of demos that showcases the different PopoverView
configurations, props and events you can use. The assets directory contains gifs and screenshots for every example/test shown in the example app.
git clone https://github.com/dominicstop/react-native-ios-popover.git
cd react-native-ios-popover && yarn bootstrap
react-native-ios-context-popover/example
directory and run yarn ios
to build/launch the example app in the iOS simulator.PopoverView
ExamplesPopoverView
Example 01A bare minimum example showing how to present a popover via the setVisibility
function.
1function PopoverViewExample01() { 2 const popoverRef = useRef(); 3 4 return ( 5 <PopoverView 6 // get/store a ref to the popover component 7 ref={popoverRef} 8 // a function that returns the content to show 9 // inside the popover 10 renderPopoverContent={() => ( 11 <View style={{padding: 20}}> 12 <Text> 13 {'Popover Content'} 14 </Text> 15 </View> 16 )} 17 > 18 <TouchableOpacity onPress={() => { 19 // show the popover when the button is pressed 20 // (note: `setVisibility` will throw an error if attempting to 21 // show a popover that's already visible) 22 // alt. you can call `toggleVisibility` to show/hide the popover 23 popoverRef.current.setVisibility(true); 24 }}> 25 <Text> 26 {'Show Popover'} 27 </Text> 28 </TouchableOpacity> 29 </PopoverView> 30 ); 31};
PopoverView
Example 02A example PopoverView
for the permittedArrowDirections
prop.
ArrowDirections
string values (e.g: 'up', 'down', etc). You can also pass in an empty array or null to specify that the popover should not have an arrow.permittedArrowDirections
.1function PopoverViewExample02() { 2 const popoverRef = useRef(); 3 4 return( 5 <PopoverView 6 ref={popoverRef} 7 // the allowed direction of the popover arrow. 8 // accepts an array of `ArrowDirections` values, 9 // e.g. "up", "down", etc. 10 permittedArrowDirections={["left"]} 11 renderPopoverContent={() => ( 12 <View style={{padding: 20}}> 13 <Text> 14 {'Left Arrow'} 15 </Text> 16 </View> 17 )} 18 > 19 <TouchableOpacity onPress={() => { 20 popoverRef.current.setVisibility(true); 21 }}> 22 <Text> 23 {'Show Popover'} 24 </Text> 25 </TouchableOpacity> 26 </PopoverView> 27 ); 28};
PopoverView
Example 03A example PopoverView
with the popoverSize
prop set to STRETCH
.
popoverSize
prop is set to INHERIT
which means the size of the popover is determined by the size of the popover content.STRETCH
, the popover will be sized to be as big as possible based on the permittedArrowDirections
prop, its position on screen, etc.1function PopoverViewExample03() { 2 const popoverRef = useRef(); 3 4 return( 5 <PopoverView 6 ref={popoverRef} 7 // set the `popoverSize` prop to `STRETCH` to make the 8 // popover as big as possible. 9 popoverSize={{type: 'STRETCH'}} 10 // You also have to set `popoverCanOverlapSourceViewRect` 11 // prop to false to prevent the popover from covering up 12 // the popover source view. 13 popoverCanOverlapSourceViewRect={false} 14 permittedArrowDirections={["up", "down"]} 15 // the style of the root popover content view must be set 16 // to `{flex: 1}` so that it'll stretch to the size of the 17 // popover. 18 renderPopoverContent={() => ( 19 <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}> 20 <Text> 21 {'Popover Content'} 22 </Text> 23 </View> 24 )} 25 > 26 <TouchableOpacity onPress={() => { 27 popoverRef.current.setVisibility(true); 28 }}> 29 <Text> 30 {'Show Popover'} 31 </Text> 32 </TouchableOpacity> 33 </PopoverView> 34 ); 35};
PopoverView
Example 04A example PopoverView
with the popoverBackgroundColor
prop set to "pink". By default, the PopoverView
has a transparent background with a blur effect.
1function PopoverViewExample04(props) { 2 const popoverRef = useRef(); 3 4 return ( 5 <PopoverView 6 ref={popoverRef} 7 // pass in a valid color value 8 popoverBackgroundColor={'pink'} 9 renderPopoverContent={() => ( 10 <View style={{padding: 20}}> 11 <Text> 12 {'Popover Content'} 13 </Text> 14 </View> 15 )} 16 > 17 <TouchableOpacity onPress={() => { 18 popoverRef.current.setVisibility(true); 19 }}> 20 <Text> 21 {'Show Popover'} 22 </Text> 23 </TouchableOpacity> 24 </PopoverView> 25 ); 26};
PopoverView
Example 05A example PopoverView
for programmatically hiding the popover via the setVisibility
function.
setVisibility(bool)
function will throw an error if it's already visible or hidden.1function PopoverViewExample05(props) { 2 const popoverRef = useRef(); 3 4 return ( 5 <PopoverView 6 ref={popoverRef} 7 onPopoverDidHideViaTap={() => alert('onPopoverDidHideViaTap')} 8 renderPopoverContent={() => ( 9 <View style={{padding: 20}}> 10 <TouchableOpacity onPress={() => { 11 // hide the popover 12 popoverRef.current.setVisibility(false); 13 }}> 14 <Text> 15 {'Dismiss Popover'} 16 </Text> 17 </TouchableOpacity> 18 </View> 19 )} 20 > 21 <TouchableOpacity onPress={() => { 22 // toggle popover visibility 23 popoverRef.current.toggleVisibility(); 24 }}> 25 <Text> 26 {'Toggle Popover'} 27 </Text> 28 </TouchableOpacity> 29 </PopoverView> 30 ); 31};
PopoverView
Example 06A simple PopoverView
example for the popover did show/hide events.
1function PopoverViewExample06(props) { 2 const popoverRef = useRef(); 3 4 return( 5 <PopoverView 6 ref={popoverRef} 7 // popover events 8 onPopoverDidHide={() => alert('onPopoverDidHide')} 9 onPopoverDidShow={() => alert('onPopoverDidShow')} 10 renderPopoverContent={() => ( 11 <View style={{padding: 20}}> 12 <Text style={styles.popoverText}> 13 {'Popover Content'} 14 </Text> 15 </View> 16 )} 17 > 18 <TouchableOpacity onPress={() => { 19 popoverRef.current.setVisibility(); 20 }}> 21 <Text> 22 {'Toggle Popover'} 23 </Text> 24 </TouchableOpacity> 25 </PopoverView> 26 ); 27};
PopoverView
Example 07A example PopoverView
that has a switch that toggles the popoverShouldDismiss
prop.
onPopoverDidAttemptToDismiss
prop is set to true
by default. This prop controls whether or not the popover should dismiss when there's a tap gesture outside the popover.onPopoverDidAttemptToDismiss
to false
will prevent the popover from dismissing via a tap outside the popover.1function PopoverViewExample07(props) { 2 const popoverRef = useRef(); 3 4 const [isEnabled, setIsEnabled] = useState(false); 5 // toggle `popoverShouldDismiss` 6 const toggleSwitch = () => setIsEnabled(previousState => !previousState); 7 8 return( 9 <PopoverView 10 ref={popoverRef} 11 // set the `popoverShouldDismiss` prop 12 popoverShouldDismiss={isEnabled} 13 onPopoverDidAttemptToDismiss={() => alert('onPopoverDidAttemptToDismiss')} 14 renderPopoverContent={() => ( 15 <View> 16 <Text> 17 {'popoverShouldDismiss'} 18 </Text> 19 <Switch 20 onValueChange={toggleSwitch} 21 value={isEnabled} 22 /> 23 </View> 24 )} 25 > 26 <TouchableOpacity onPress={() => { 27 popoverRef.current.setVisibility(true); 28 }}> 29 <Text> 30 {'Show Popover'} 31 </Text> 32 </TouchableOpacity> 33 </PopoverView> 34 ); 35};
PopoverView
Example 08A example PopoverView
for the toggleVisibility
function.
1function PopoverViewExample08(props) { 2 const popoverRef = useRef(); 3 4 return( 5 <PopoverView 6 ref={popoverRef} 7 popoverShouldDismiss={false} 8 renderPopoverContent={() => ( 9 <View style={{padding: 20}}> 10 <Text> 11 {'Popover Content'} 12 </Text> 13 </View> 14 )} 15 > 16 <TouchableOpacity onPress={() => { 17 // toggle the popover visibility 18 popoverRef.current.toggleVisibility(); 19 }}> 20 <Text> 21 {'Toggle Popover'} 22 </Text> 23 </TouchableOpacity> 24 </PopoverView> 25 ); 26};
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
45 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More