Reputation: 101
I am new to React.js. We use the material-io CSS framework to build our app.
I have a task to display menu items of in a dropdown menu, which opens to the top or bottom based on the position of the menu when it is opened on a mobile device..
It is similar to the Facebook video section when the user clicks the (...)-icon it shows the options based on the screen position of the icon.
Facebook menu bottom appear
Upvotes: 1
Views: 495
Reputation: 83
You Can Use react-power-tooltip. For Use:
Install From Npm
$ npm install react-power-tooltip --save
import To Project
import Tooltip from 'react-power-tooltip'
Add a hover state & mouse event handler to the enclosing target component
class Test extends Component {
state = {
show: false
}
showTooltip = bool => {
this.setState({ show: bool })
}
render() {
return (
{/* Target element position needs to be RELATIVE */}
<div
style={{ position: 'relative' }}
onMouseOver={() => this.showTooltip(true)}
onMouseLeave={() => this.showTooltip(false)}>
{/* ADD TOOLTIP HERE */}
</div>
);
}
}
export default Test;
Add the tooltip inside the target element
{/* Add options/text via span elements */}
<Tooltip show={this.state.show}>
<span>Some text</span>
</Tooltip>
For More Information: https://justinrhodes1.github.io/react-power-tooltip/
Upvotes: 0
Reputation: 191
You can make use of a library that provides a tooltip menu. For example https://justinrhodes1.github.io/react-power-tooltip/
Upvotes: 1