Skip to content

Commit 5f19172

Browse files
author
Guillaume Chau
committed
Docs
1 parent 8bc2448 commit 5f19172

File tree

1 file changed

+81
-53
lines changed

1 file changed

+81
-53
lines changed

README.md

Lines changed: 81 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Or a reactive property:
216216
<button v-tooltip="options">
217217
```
218218

219-
- `content` - HTML text to be displayed in the tooltip.
219+
- `content` - HTML text to be displayed in the tooltip. Can also be a function that returns the content or a Promise.
220220
- `classes` - *(see above)*
221221
- `targetClasses` - CSS classes added to the target element of the tooltip.
222222
- `delay` - Show/Hide delay, or object: `{ show: 500, hide: 100 }` (ms).
@@ -230,10 +230,26 @@ Or a reactive property:
230230
- `arrowSelector` - CSS selector to get the arrow element in the tooltip template.
231231
- `innerSelector` - CSS selector to get the inner content element in the tooltip template.
232232
- `autoHide` - Boolean: automatically close the tooltip on mouseover.
233+
- `loadingClass` - CSS classes added to the tooltip when content is loading.
234+
- `loadingContent` - Same as `content`, used when the actual tooltip content is loading.
233235
- `popperOptions` - Other Popper.js options.
234236

235237
You can change the default values in the [Global options](#global-options).
236238

239+
### Async content example
240+
241+
The `content` option accepts a promise:
242+
243+
```html
244+
<button
245+
v-tooltip="{
246+
content: asyncMethod(),
247+
loadingContent: 'Please wait...',
248+
loadingClass: 'content-is-loading',
249+
}"
250+
>Hover me!</button>
251+
```
252+
237253
### Manual trigger example
238254

239255
Use the `trigger` and `show` options:
@@ -340,6 +356,7 @@ By default, the popover will have the `tooltip` and `popover` classes, so you ca
340356
- `popoverInnerClass` - Class of the inner content element.
341357
- `autoHide` - Hide the popover if clicked outside.
342358
- `handleResize` - Automatically update the popover position if its size changes.
359+
- `open-group` - If set, will close all the open popovers that have a different `open-group` value or unset.
343360

344361
You can change the default values in the [Global options](#global-options).
345362

@@ -351,6 +368,7 @@ You can change the default values in the [Global options](#global-options).
351368
- `dispose`
352369
- `auto-hide` - Emitted when the popover is closed if clicked outside.
353370
- `close-directive` - Emitted when the popover is closed with the [Close directive](#close-directive).
371+
- `close-group` - Emitted when the popover is closed because a popover of another `open-group` was shown.
354372
- `resize` - Emitted when the content size changes. You must set the `handleResize` prop to `true`.
355373

356374
### Disable popover
@@ -402,64 +420,74 @@ data () {
402420
}
403421
```
404422

423+
Close all the popovers in the page with the `all` modifier:
424+
425+
```html
426+
<a v-close-popover.all>Close All</a>
427+
```
428+
405429
## Global options
406430

407431
The default global options are:
408432

409433
```javascript
410434
{
411-
// Default tooltip placement relative to target element
412-
defaultPlacement: 'top',
413-
// Default CSS classes applied to the tooltip element
414-
defaultClass: 'vue-tooltip-theme',
415-
// Default CSS classes applied to the target element of the tooltip
416-
defaultTargetClass: 'has-tooltip',
417-
// Default HTML template of the tooltip element
418-
// It must include `tooltip-arrow` & `tooltip-inner` CSS classes (can be configured, see below)
419-
// Change if the classes conflict with other libraries (for example bootstrap)
420-
defaultTemplate: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
421-
// Selector used to get the arrow element in the tooltip template
422-
defaultArrowSelector: '.tooltip-arrow, .tooltip__arrow',
423-
// Selector used to get the inner content element in the tooltip template
424-
defaultInnerSelector: '.tooltip-inner, .tooltip__inner',
425-
// Delay (ms)
426-
defaultDelay: 0,
427-
// Default events that trigger the tooltip
428-
defaultTrigger: 'hover focus',
429-
// Default position offset (px)
430-
defaultOffset: 0,
431-
// Default container where the tooltip will be appended
432-
defaultContainer: 'body',
433-
defaultBoundariesElement: undefined,
434-
defaultPopperOptions: {},
435-
// Hide on mouseover tooltip
436-
autoHide: true,
437-
// Auto destroy tooltip DOM nodes (ms)
438-
disposeTimeout: 5000,
439-
// Options for popover
440-
popover: {
441-
defaultPlacement: 'bottom',
442-
// Use the `popoverClass` prop for theming
443-
defaultClass: 'vue-popover-theme',
444-
// Base class (change if conflicts with other libraries)
445-
defaultBaseClass: 'tooltip popover',
446-
// Wrapper class (contains arrow and inner)
447-
defaultWrapperClass: 'wrapper',
448-
// Inner content class
449-
defaultInnerClass: 'tooltip-inner popover-inner',
450-
// Arrow class
451-
defaultArrowClass: 'tooltip-arrow popover-arrow',
452-
defaultDelay: 0,
453-
defaultTrigger: 'click',
454-
defaultOffset: 0,
455-
defaultContainer: 'body',
456-
defaultBoundariesElement: undefined,
457-
defaultPopperOptions: {},
458-
// Hides if clicked outside of popover
459-
defaultAutoHide: true,
460-
// Update popper on content resize
461-
defaultHandleResize: true,
462-
},
435+
// Default tooltip placement relative to target element
436+
defaultPlacement: 'top',
437+
// Default CSS classes applied to the tooltip element
438+
defaultClass: 'vue-tooltip-theme',
439+
// Default CSS classes applied to the target element of the tooltip
440+
defaultTargetClass: 'has-tooltip',
441+
// Default HTML template of the tooltip element
442+
// It must include `tooltip-arrow` & `tooltip-inner` CSS classes (can be configured, see below)
443+
// Change if the classes conflict with other libraries (for example bootstrap)
444+
defaultTemplate: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
445+
// Selector used to get the arrow element in the tooltip template
446+
defaultArrowSelector: '.tooltip-arrow, .tooltip__arrow',
447+
// Selector used to get the inner content element in the tooltip template
448+
defaultInnerSelector: '.tooltip-inner, .tooltip__inner',
449+
// Delay (ms)
450+
defaultDelay: 0,
451+
// Default events that trigger the tooltip
452+
defaultTrigger: 'hover focus',
453+
// Default position offset (px)
454+
defaultOffset: 0,
455+
// Default container where the tooltip will be appended
456+
defaultContainer: 'body',
457+
defaultBoundariesElement: undefined,
458+
defaultPopperOptions: {},
459+
// Class added when content is loading
460+
defaultLoadingClass: 'tooltip-loading',
461+
// Displayed when tooltip content is loading
462+
defaultLoadingContent: '...',
463+
// Hide on mouseover tooltip
464+
autoHide: true,
465+
// Auto destroy tooltip DOM nodes (ms)
466+
disposeTimeout: 5000,
467+
// Options for popover
468+
popover: {
469+
defaultPlacement: 'bottom',
470+
// Use the `popoverClass` prop for theming
471+
defaultClass: 'vue-popover-theme',
472+
// Base class (change if conflicts with other libraries)
473+
defaultBaseClass: 'tooltip popover',
474+
// Wrapper class (contains arrow and inner)
475+
defaultWrapperClass: 'wrapper',
476+
// Inner content class
477+
defaultInnerClass: 'tooltip-inner popover-inner',
478+
// Arrow class
479+
defaultArrowClass: 'tooltip-arrow popover-arrow',
480+
defaultDelay: 0,
481+
defaultTrigger: 'click',
482+
defaultOffset: 0,
483+
defaultContainer: 'body',
484+
defaultBoundariesElement: undefined,
485+
defaultPopperOptions: {},
486+
// Hides if clicked outside of popover
487+
defaultAutoHide: true,
488+
// Update popper on content resize
489+
defaultHandleResize: true,
490+
},
463491
}
464492
```
465493

0 commit comments

Comments
 (0)