ReactNative component showing tooltip with menu items.
npm install react-native-popover-tooltipCurrently works only with iOS and Android.
This component is modified from another project react-native-tooltip-menu
``bash`
npm install react-native-popover-tooltip --save
To use the component, import the component as shown below
`js`
import PopoverTooltip from 'react-native-popover-tooltip';

`javascript
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
order: 1
};
}
render() {
return (
buttonComponent={
Press Me
}
items={[
{
label: 'Item 1',
onPress: () => {}
},
{
label: 'Item 2',
onPress: () => {}
}
]}
// animationType='timing'
// using the default timing animation
/>
buttonComponent={
Press Me
}
items={[
{
label: 'Item 1',
onPress: () => {}
},
{
label: 'Item 2',
onPress: () => {}
}
]}
animationType='spring' // spring-damper animation
springConfig={{tension: 100, friction: 3}} // tension controls the potential of the spring effect,
// friction controls the damper effect
/>
buttonComponent={
Press Me
}
items={[
{
label: 'Item 1',
onPress: () => {}
},
{
label: 'Item 2',
onPress: () => {}
}
]}
animationType='spring'
buttonComponentExpandRatio={1.2} // ratio of button component expansion after tooltip poped up
/>
buttonComponent={
Press Me
}
items={[
{
label: 'Item 1',
onPress: () => {}
},
{
label: 'Item 2',
onPress: () => {}
}
]}
animationType='spring'
overlayStyle={{backgroundColor: 'transparent'}} // set the overlay invisible
tooltipContainerStyle={{borderRadius:0}}
labelContainerStyle={{backgroundColor: '#ED5736', width: 120, alignItems: 'center'}}
labelSeparatorColor='#1BD1A5' />
buttonComponent={
Press Me
}
items={[
{
label: 'Item 1',
onPress: () => {}
},
{
label: 'Item 2',
onPress: () => {}
}
]}
// animationType='timing'
// using the default timing animation
timingConfig={{duration: 1000}}
opacityChangeDuration={1000} />
onPress={() => {
this.refs['tooltip'+this.state.order].toggle(); // open popover tooltips one by one
this.setState({order: (this.state.order)%5+1 });
}}>
Open Tooltip {this.state.order}
);
}
}
`
| Property | Type | Default | Description |
|----------------|---------------|-----------|--------------------------------------|
| buttonComponent | node ||| Component that can be long pressed
| items | Array | | Items to be rendered in menu. Each of item requires label as string or function if you want to render your own component and onClick as function to be called when you click item. |Object
| componentWrapperStyle | Object | Optional | Style if you want to overwrite wrapper for your buttonComponentObject
| componentContainerStyle | Object | Optional | Style if you want to overwrite container that is between wrapper and your buttonComponentObject
| overlayStyle | Object | Optional | Style if you want to overwrite overlay style's.function
| onRequestClose | | Optional, default () => {} | Modal onRequestClose required function on Android Object
| labelContainerStyle | | Optional | Style Object if you want to change default TooltipMenuItem View's style.Object
| tooltipContainerStyle | | Optional | Style of the container of the entire tooltip menu.Object
| labelStyle | | Optional | Style Object if you want to change default TooltipMenuItem Text's style.String
| labelSeparatorColor | | Color of the separator between two tooltip menu items.String
| animationType | | timing | Tooptip popping animation. timing = popup within a specific duration, spring = popup with a spring bumper model.Object
| timingConfig | | {duration: 200} | Configuration of timing animation. Attribute duration is the duration of the animation.Object
| springConfig | | {tension: 100, friction: 7} | Configuration of spring animation. Attributes tension and friction control the behavior of the spring bumper effect.number
| opacityChangeDuration | | 200 | Duration of opacity change of the overlay, during both appearance and dispearance.number
| buttonComponentExpandRatio | | 1.0 | Ratio of button component expansion after tooltip poped up.Boolean
| setBelow | | false | Sets the default position of the tooltip to appear below the intended target.Number` | 0 | Number of pixels to offset triangle from center. Positive numbers will push right. Negative Numbers will push left.
| triangleOffset |
| Property | Description |
|----------------|---------------|
| toggle | Open or hide popover tooltip |