Skip to content

Commit

Permalink
docs: add html file example
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Jun 20, 2020
1 parent c420fcf commit 335c2db
Show file tree
Hide file tree
Showing 4 changed files with 2,825 additions and 2,149 deletions.
3 changes: 1 addition & 2 deletions website/src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
MEDIA,
ExternalLink,
} from './Framework';
import Tippy, {TippySingleton} from './Tippy';
import Tippy from './Tippy';
import Nav from './Nav';
import NavButtons from './NavButtons';
import Header from './Header';
Expand Down Expand Up @@ -124,7 +124,6 @@ class Heading extends React.Component {

const components = {
Tippy,
TippySingleton,
Demo,
Button,
Row,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
---
title: Creation
path: /v6/creation/
title: Constructor
path: /v6/constructor/
index: 2
---

Give elements you would like to give tooltips to a `data-tippy-content`
attribute:
The `tippy()` constructor (a plain function) creates individual tippy instances.
To give the tippy content you have two options:

### Attribute

With some elements on the document:

```html
<button data-tippy-content="Tooltip">Text</button>
<button data-tippy-content="Another Tooltip">Text</button>
```

To give them a tippy tooltip, call the `tippy()` function with a CSS selector
matching these elements:
Call the `tippy()` constructor with a CSS selector matching them:

```js
tippy('[data-tippy-content]');
```

The `data-tippy-content` attribute allows you to give different tooltip content
to many different elements, while only needing to initialize once.
### Prop

If targeting a single element, you can use the `content` prop instead of the
attribute:
Expand Down
23 changes: 23 additions & 0 deletions website/src/pages/v6/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ don't get removed.
> (`tippy-bundle`). With CSP enabled, you may need to separately link
> `dist/tippy.css` and use `dist/tippy.umd.min.js` instead.
### Usage

```html
<html>
<head>
<title>Tippy</title>
</head>
<body>
<button id="myButton">My button</button>

<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<script>
// With the above scripts loaded, you can call `tippy()` with a CSS
// selector and a `content` prop:
tippy('#myButton', {
content: 'My tooltip!',
});
</script>
</body>
</html>
```

### React

Using React? Use the
Expand Down
Loading

0 comments on commit 335c2db

Please sign in to comment.