GithubHelp home page GithubHelp logo

noahwelch / react-tt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from orzechowskid/react-tt

0.0 1.0 0.0 1.93 MB

no-fuss React tooltips

License: MIT License

JavaScript 91.93% CSS 3.29% HTML 4.79%

react-tt's Introduction

react-tt

no-fuss React tooltips

About

I didn't especially like any of the React tooltip libraries I found out there; either they didn't fit my use-case, they were too big, or they plain didn't work. react-tt is tiny (~6KB prod-minified), it won't screw up your layout with extra elements, and it tries hard to ensure all tooltip contents fit inside the viewport.

Getting Started

$ npm install --save react-tt

Usage

import/require the module in your usual way:

import Tooltip from 'react-tt';

and instantiate using <Tooltip> (in JSX) or React.createElement(Tooltip) (in vanilla JS). Not much to it.

Here's a simple example in ES6:

import Tooltip from 'react-tt';

function HelloComponent(props) {
  return (
    <div>
      <Tooltip>
        <span>
          hello
        </span>
      </Tooltip>
      <span>
        hover over me
      </span>
    </div>
  );
}

export default MyComponent

for live examples, clone this repository and run npm run example then visit localhost:8080 or just go to https://orzechowskid.github.io/react-tt/ .

API

Tooltip

React.createElement(Tooltip, props, children)

creates a new Tooltip component with the given props and, optionally, some children.

props.backgroundColor: PropTypes.string

specifies the background color for the tooltip. Valid values are anything accepted by CSS:

  • color names like red or salmon
  • hex strings like #f8f8f8
  • rgb or rgba strings like rgba(255, 255, 255, 0.5)
  • hsl strings like hsl(214, 82%, 51%)

props.id: PropTypes.string.isRequired

specifies the id of the tooltip.

props.location: PropTypes.oneOf([ 'bottom', 'top' ])

specifies the orientation of the tooltip relative to its container. Defaults to top.

props.spacing: PropTypes.number

specifies the spacing between the tooltip's indicator and its container. Defaults to 14 (px).

props.sticky: PropTypes.bool

specifies the tooltip to always be shown. Defaults to false.

props.zIndex: PropTypes.number

specifies the tooltip's z-index. Defaults to 0.

Development

$ git clone https://www.github.com/orzechowskid/react-tt.git
$ npm install
$ cd src
[ ... edit edit edit ... ]
$ npm run example
$ open http://localhost:8808
[ ... verify verify verify ... ]
$ npm run build:prod

Testing

npm run test should run the test suite. please update it if you add features.

react-tt's People

Contributors

dependabot[bot] avatar orzechowskid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.