Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

Commit e5bff64

Browse files
committed
Add documentation for isVisible and isEnabled props
1 parent 8ed0123 commit e5bff64

File tree

1 file changed

+67
-13
lines changed

1 file changed

+67
-13
lines changed

README.md

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,84 @@ const TooltipWithProps = () => (
4242
</Tippy>
4343
)
4444

45-
// Special `onCreate` callback prop that passes the tippy instance
46-
class TooltipWithOnCreate extends React.Component {
47-
render() {
48-
return (
49-
<Tippy content="Hi" onCreate={tip => (this.tip = tip)}>
50-
<button>My button</button>
51-
</Tippy>
52-
)
53-
}
54-
}
55-
5645
const App = () => (
5746
<main>
5847
<RegularTooltip />
5948
<TooltipWithJSX />
6049
<TooltipWithProps />
61-
<TooltipWithOnCreate />
6250
</main>
6351
)
6452

6553
ReactDOM.render(<App />, document.getElementById('root'))
6654
```
6755

68-
See the [Tippy.js docs](https://atomiks.github.io/tippyjs/) for the rest of the props you can supply.
56+
## Native props
57+
58+
See the [Tippy.js docs](https://atomiks.github.io/tippyjs/#all-options)
59+
60+
## React-specific props
61+
62+
### `isEnabled?: boolean`
63+
64+
Prop to control the `tippy.enable()` / `tippy.disable()` instance methods. Use this when you want to temporarily disable a tippy from showing.
65+
66+
```jsx
67+
class App extends Component {
68+
state = {
69+
isEnabled: true
70+
}
71+
72+
render() {
73+
return (
74+
<Tippy isEnabled={this.state.isEnabled}>
75+
<button />
76+
</Tippy>
77+
)
78+
}
79+
}
80+
```
81+
82+
### `isVisible?: boolean`
83+
84+
Prop to control the `tippy.show()` / `tippy.hide()` instance methods. Use this when you want to programmatically show or hide the tippy instead of relying on UI events.
85+
86+
⚠️ **It must be accompanied by a `"manual"` trigger prop.**
87+
88+
```jsx
89+
class App extends Component {
90+
state = {
91+
isVisible: true
92+
}
93+
94+
render() {
95+
return (
96+
<Tippy trigger="manual" isVisible={this.state.isVisible}>
97+
<button />
98+
</Tippy>
99+
)
100+
}
101+
}
102+
```
103+
104+
### `onCreate?: (tip: Instance) => void`
105+
106+
Callback invoked when the Tippy instance has been created. Use this when you need to store the Tippy instance on the component.
107+
108+
```jsx
109+
class App extends Component {
110+
storeTippyInstance = tip => {
111+
this.tip = tip
112+
}
113+
114+
render() {
115+
return (
116+
<Tippy onCreate={this.storeTippyInstance}>
117+
<button />
118+
</Tippy>
119+
)
120+
}
121+
}
122+
```
69123

70124
## Default props and themes
71125

0 commit comments

Comments
 (0)