1.0.0 • Published 2 years ago

@programic/vue3-tooltip v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Vue 3 & Nuxt 3 Tooltip

npm version Vue 3 Bundle codecov

vt

Features

  • Vue 3 compatible!
  • Nuxt 3 compatible!
  • Generic registration allows it to be used inside any app!
  • Fully written in Typescript with full types support
  • Easy to set up for real, you can make it work in less than 10sec!
  • Customize everything
  • Use your custom components as the tooltip body for endless possibilities!
  • Define behavior per tooltip
  • Use your themes and animations easily
  • And much more!

Installation

$ yarn add @programic/vue3-tooltip
$ npm install --save @programic/vue3-tooltip

Usage

Plugin registration

Add it as a plugin to your app:

import { createApp } from "vue";
import Tooltip from "@programic/vue3-tooltip";
// Import the CSS or use your own!
import '@programic/vue3-tooltip/dist/index.css';

const app = createApp(...);

const options = {
    // You can set your default options here
};

app.use(Tooltip, options);

Or, if you are using Typescript:

import { createApp } from "vue";
import Tooltip from '@programic/vue3-tooltip';
import type { TooltipConfiguration } from '@programic/vue3-tooltip';

// Import the CSS or use your own!
import '@programic/vue3-tooltip/dist/index.css';

const app = createApp(...);

const options: TooltipConfiguration = {
    // You can set your default options here
};

app.use(Tooltip, options);

Or, if you are using Nuxt 3:

Create a tooltip.ts in the plugins folder with the following code

// tooltip.ts
import { defineNuxtPlugin } from "#app";
import Tooltip from '@programic/vue3-tooltip';

export default defineNuxtPlugin(nuxtApp => {
    nuxtApp.vueApp.use(Tooltip)
});

Creating tooltips by directive

To create tooltips by directive, add v-tooltip on your element

<p><span v-tooltip="this is a tooltip">Hover me</span></p>

Creating tooltips by component

For more options and configurations use tooltip by a component

<script>
    import { Tooltip } from '@programic/vue3-tooltip';
</script>

<template>
    <Tooltip title="tooltip test">Hover me</Tooltip>
</template>

Positioning the Tooltip

By default, the tooltip will be displayed at the top of the element, but you can set it manually using the placement option.

You can use the type definitions or one of the allowed values: top, right, bottom, left.

import Tooltip from '@programic/vue3-tooltip';

app.use(Tooltip, {
    // Setting the global default position
    position: 'bottom',
});


// Or set it per tooltip
<Tooltip title="tooltip test" placement="bottom">Hover me</Tooltip>

Tooltip types

Depending on the context, you may want to use tooltips of different colors. You can easily do that by setting the type of tooltip to be displayed.

<Tooltip title="tooltip test" type="light">Hover me</Tooltip>

// You can also set the type programmatically when calling the default toast
import Tooltip from '@programic/vue3-tooltip';

app.use(Tooltip, {
    // Setting the global default type
    type: 'light',
});

API

Plugin registration (app.use)

OptionTypeDefaultDescription
placementStringtopPosition of the toast on the screen. Can be any of top-right, top-center, top-left, bottom-right, bottom-center, bottom-left.
containerObject or BooleantrueWhether or not the newest toasts are placed on the top of the stack.

Tooltip (props)

PropsTypeRequiredDescription
containerHTMLElementNoOverride global container config where tooltip needs teleported)
triggerStringNoWhen the tooltip opens
placementStringNoThe position of the tooltip
sizeStringNoThe tooltip size
typeStringNoThe tooltip type
titleStringNoThe tooltip title
descriptionStringNoThe tooltip description

License

Copyright (C) 2022 Programic. Licensed under MIT

1.0.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago