mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
30 lines
716 B
JavaScript
30 lines
716 B
JavaScript
import React, { useState } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
const Tooltip = ({ content, children }) => {
|
|
const [visible, setVisible] = useState(false);
|
|
|
|
return (
|
|
<div className="relative inline-block">
|
|
<div
|
|
onMouseEnter={() => setVisible(true)}
|
|
onMouseLeave={() => setVisible(false)}
|
|
className="cursor-pointer"
|
|
>
|
|
{children}
|
|
</div>
|
|
{visible && (
|
|
<div className="absolute z-10 w-64 p-2 bg-white border border-gray-200 rounded shadow-lg">
|
|
{content}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
Tooltip.propTypes = {
|
|
content: PropTypes.node.isRequired,
|
|
children: PropTypes.node.isRequired,
|
|
};
|
|
|
|
export default Tooltip; |