Skip to content

Commit

Permalink
docs: imperative mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieljablonski committed Nov 1, 2023
1 parent f53d1c9 commit d50dde7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions docs/docs/examples/imperative-mode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,23 @@ interface TooltipImperativeProps {
}
```

- `open()` opens the tooltip programatically. All of the function arguments are optional
#### Methods

:::info

The imperative methods <b>can</b> be applied alongside regular tooltip usage. For example, you could use just `close()` to close a regular tooltip after an API request is finished.

:::

- `open()` opens the tooltip programatically. All of the arguments are optional
- `anchorSelect` overrides the selector currently in use. Ideally, it should match only one element (e.g. `#some-element`)
- `position` overrides the tooltip position. Behaves the same way as the `position` tooltip prop
- `place` overrides the tooltip placement relative to the anchor. Behaves the same was the `place` tooltip prop
- `content` overrides the tooltip content
- `close()` closes the tooltip programatically

#### Internal state

:::note

These are read-only. Updating their values has no effect on the tooltip.
Expand All @@ -87,12 +97,6 @@ These are read-only. Updating their values has no effect on the tooltip.
- `place` is the current tooltip placement relative to the anchor element. Can differ from the `place` tooltip prop if the tooltip is close to the edges of its container
- `isOpen` indicates whether the tooltip is currently being shown or not

:::info

The imperative methods <b>can</b> be applied alongside regular tooltip usage. For example, you could use just `close()` to close a regular tooltip after an API request is finished.

:::

```jsx
import { useRef } from 'react';
import { Tooltip, TooltipImperativeProps } from 'react-tooltip';
Expand Down

0 comments on commit d50dde7

Please sign in to comment.