tulitip

1.0.9 • Public • Published

tulitip

This is a simple Tooltip created for studies purpose.

It has some repositioning logic based on the target's specified parent, if none is passed, it assumes the body as it's parent.

The usage is basically:

import { useRef, useState } from 'react';

import Tooltip from '../../Tooltip';

export function Sample01 () {
    const [isOpen, setIsOpen] = useState(false);

    const targetRef = useRef({});
    const parentTargetRef = useRef({});

    return (
        <div ref={parentTargetRef} className='container'>
            <div
                ref={targetRef}
                className='target'
                onClick={
                    () => setIsOpen(!isOpen)
                }
            ></div>

            <Tooltip
                targetElement={targetRef.current}
                isOpen={isOpen}
                preferredPositions={['bottom', 'top', 'left', 'right']}
                targetParentElement={parentTargetRef.current}
                paddingAroundTarget={10}
                containerStyle={
                    { "z-index": "-1" }
                }
            >
                <div className='tooltipContainer'>
                    <span>My Tooltip!</span>
                </div>
            </Tooltip>
        </div>
    );
}

Only depends on React for usage.

Improvements

  • [ ] Add some events for the Tooltip component
  • [ ] Create more options to give more control for the user

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.90latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.90
1.0.80
1.0.71
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i tulitip

Weekly Downloads

1

Version

1.0.9

License

MIT

Unpacked Size

42.4 kB

Total Files

5

Last publish

Collaborators

  • julionm