# ak-tooltip

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

Latest version **6.0.3** (published 2017-01-03) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ak-tooltip
pnpm add ak-tooltip
yarn add ak-tooltip
bun add ak-tooltip
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 6.0.3 |
| Published | 2017-01-03 |
| First published | 2016-09-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Atlassian Pty Ltd |
| Maintainers | atlassian-aui |
| Keywords | atlaskit, ui |

## Links

- npm: https://www.npmjs.com/package/ak-tooltip
- Repository: https://bitbucket.org/atlassian/atlaskit
- Homepage: https://bitbucket.org/atlassian/atlaskit#readme
- npm.io page: https://npm.io/package/ak-tooltip

## Dependencies (3)

- [ak-layer](https://npm.io/package/ak-layer.md) ^62.0.2
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.11.6
- [akutil-shared-styles](https://npm.io/package/akutil-shared-styles.md) ^37.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 6.0.3 (latest) — 2017-01-03
- 6.0.2 — 2016-12-20
- 6.0.1 — 2016-12-07
- 5.0.4 — 2016-11-17
- 5.0.3 — 2016-11-09
- 5.0.2 — 2016-11-08
- 5.0.1 — 2016-11-08
- 5.0.0 — 2016-11-07
- 4.0.0 — 2016-11-07
- 3.0.2 — 2016-11-03
- 3.0.1 — 2016-11-03
- 3.0.0 — 2016-11-02
- 2.1.1 — 2016-11-02
- 2.1.0 — 2016-10-19
- 2.0.7 — 2016-10-17
- … 6 more at https://npm.io/package/ak-tooltip/versions

## README

[![AtlasKit component registry](https://img.shields.io/badge/AtlasKit-components-FF5230.svg)](http://aui-cdn.atlassian.com/atlaskit/registry/)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://Commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/GitHub-semantic_release-ffab00.svg)](https://github.com/semantic-release/semantic-release)
[![Report an issue](https://img.shields.io/badge/Report-an_issue-6554C0.svg)](https://ecosystem.atlassian.net/browse/AK)
[![Ask in our forum](https://img.shields.io/badge/Ask-in_our_forum-6554C0.svg)](https://answers.atlassian.com/questions/ask?title=AtlasKit%3A%20&topics=atlaskit,ak-tooltip,ak-tooltip@6.0.3)

# Tooltip

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

![Example tooltip](https://bytebucket.org/atlassian/atlaskit/raw/faeb8e22b4d21b5d42587408fa0ba409b7120a33/packages/ak-tooltip/docs/exampleTooltip.gif)

## Installation

```sh
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

```js
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


```js
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.

<a name="Tooltip"></a>

## Tooltip
**Kind**: global class  
* Properties

    *  [tooltip.position](#Tooltip+position) : <code>string</code>
    *  [tooltip.description](#Tooltip+description) : <code>string</code>
    *  [tooltip.visible](#Tooltip+visible) : <code>boolean</code>

<a name="new_Tooltip_new"></a>

### new Tooltip()
React component used to display floating tooltips next to a component.

**HTML Example**
```js
<AKTooltip description="Foo!" position="right"><div>Foo</div></AKTooltip>
```
<a name="Tooltip+position"></a>

### tooltip.position : <code>string</code>
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 <code>[Tooltip](#Tooltip)</code>  
**Default**: <code>&quot;bottom&quot;</code>  
<a name="Tooltip+description"></a>

### tooltip.description : <code>string</code>
The text to display in the tooltip when a user hovers over the element.

**Kind**: instance property of <code>[Tooltip](#Tooltip)</code>  
**Default**: <code>&quot;&#x27;&#x27;&quot;</code>  
<a name="Tooltip+visible"></a>

### tooltip.visible : <code>boolean</code>
Whether or not the tooltip is open and visible on the page.

**Kind**: instance property of <code>[Tooltip](#Tooltip)</code>  
**Default**: <code>false</code>  

## 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](https://answers.atlassian.com/questions/ask?title=AtlasKit%3A%20&topics=atlaskit,ak-tooltip,ak-tooltip@6.0.3).

Check [if someone has already asked the same question before](https://answers.atlassian.com/questions/topics/42926171/atlaskit).


### Create a support ticket

Are you in trouble? [Let us know](https://ecosystem.atlassian.net/browse/AK)!

---
_Source: https://npm.io/package/ak-tooltip · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
