6.0.3 • Published 7 years ago

ak-tooltip v6.0.3

Weekly downloads
11
License
Apache-2.0
Repository
bitbucket
Last release
7 years ago

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 ak-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 'ak-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 'ak-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!

6.0.3

7 years ago

6.0.2

7 years ago

6.0.1

7 years ago

5.0.4

8 years ago

5.0.3

8 years ago

5.0.2

8 years ago

5.0.1

8 years ago

5.0.0

8 years ago

4.0.0

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.7

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago