Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atlaskit/tooltip

Package Overview
Dependencies
Maintainers
1
Versions
232
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atlaskit/tooltip

This component is used to display extra information to a user about an element by displaying a floating description.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
67K
increased by0.03%
Maintainers
1
Weekly downloads
 
Created
Source

AtlasKit component registry Commitizen friendly semantic-release Report an issue Ask in our forum

Tooltip

Use this component to display extra information about an element by displaying a floating description.

Example tooltip

Installation

npm install @atlaskit/tooltip

Using the component

ak-tooltip exports two tooltip components, one "smart" and one "dumb". The smart component allows you to simply place the tooltip around an element and all the state handling will be handled for you. The dumb one on the other hand allows you to hook into events and to manage the state yourself.

Smart Component

import Tooltip from '@atlaskit/tooltip';

ReactDOM.render(<div>
  <Tooltip description="Opens the user preferences screen in a new window" position="bottom">
    <button>I do something!</button>
  </Tooltip>
</div>, container);

In this case, the only props you need to use are description and position (and the content you want to bind the tooltip to).

If a user were to hover over this button, they would see a tooltip rendered underneath it. If there was not enought space below, the tooltip would automatically move to the top.

Dumb Component

import { AKTooltip } from '@atlaskit/tooltip';
let tooltipVisibleState = false;

function handleMouseOver() {
  tooltipVisibleState = true;
  renderButtonInContainer();
}

function handleMouseOut() {
  tooltipVisibleState = false;
  renderButtonInContainer();
}

function renderButtonInContainer() {
  ReactDOM.render(<div>
    <AKTooltip
      description="Opens the user preferences screen in a new window"
      position="bottom"
      visible={tooltipVisibleState}
      onMouseOver={handleMouseOver}
      onMouseOut={handleMouseOut}
    >
      <button>I do something!</button>
    </AKTooltip>
  </div>, container);
}

This is a contrived example to show the usage of onMouseOver and onMouseOut as a way of controlling your own state.

Obviously your state would normally be stored in a component or value store.

Tooltip

Kind: global class

new Tooltip()

React component used to display floating tooltips next to a component.

HTML Example

<AKTooltip description="Foo!" position="right"><div>Foo</div></AKTooltip>

tooltip.position : string

The location of where the tooltip will appear, relative to the component it is bound to. Allowed values: top, bottom, left and right.

Kind: instance property of Tooltip
Default: "bottom"

tooltip.description : string

The text to display in the tooltip when a user hovers over the element.

Kind: instance property of Tooltip
Default: "''"

tooltip.visible : boolean

Whether or not the tooltip is open and visible on the page.

Kind: instance property of Tooltip
Default: false

Support and feedback

We're here to help!

Let us know what you think of our components and docs, your feedback is really important for us.

Community support

Ask a question in our forum.

Check if someone has already asked the same question before.

Create a support ticket

Are you in trouble? Let us know!

Keywords

FAQs

Package last updated on 29 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc