1.1.2 • Published 2 years ago
simple-tooltip-react v1.1.2
simple-tooltip-react
This library is a simple ToolTip Component without any dependencies except React.
Follow simple guide to use it.
Documentation - livemehere-dev-packs
Features
- Support
hoverandclicktrigger. - Support
top,bottom,left,rightdirection. - Customize
marginandpositionto adjust tooltip position. - Support custom
colorandarrowSize. - Support
forceShowto show tooltip without trigger. disabledprops to disable tooltip.onChangeFinalShowto listen final show state change.
Tips
- Set Arrow size to 0 to hide arrow.
- Set color to
transparentto hide background. Only depends on your content.
Installation
npm install simple-tooltip-react
yarn add simple-tooltip-reactExample
// That's it. You can use it anywhere.
<ToolTip content={<div>tool</div>}>
<div style={{ display: "inline-block", margin: "100px 100px" }}>A</div>
</ToolTip>API
export type ToolTipPosition = {
top: number;
left: number;
};
interface Props {
content: ReactNode;
dir?: "top" | "bottom" | "left" | "right"; // default: top
children: JSX.Element;
margin?: number;
trigger?: "hover" | "click"; // default: hover
forceShow?: boolean;
arrowSize?: number;
color?: string; // default: black
position?: ToolTipPosition;
disabled?: boolean;
onChangeFinalShow?: (show: boolean) => void;
}