Skip to content

Instantly share code, notes, and snippets.

@gokhantaskan
Last active February 20, 2023 07:06
Show Gist options
  • Save gokhantaskan/5d0598107f80a9b9f807a1ab44df8789 to your computer and use it in GitHub Desktop.
Save gokhantaskan/5d0598107f80a9b9f807a1ab44df8789 to your computer and use it in GitHub Desktop.
Simple Vue `v-tippy` directive
import "tippy.js/dist/tippy.css";
import "tippy.js/animations/scale.css";
import tippy, {
type DefaultProps as DefaultTippyProps,
type Props as TippyProps,
} from "tippy.js";
import type { Directive } from "vue";
const defaultProps: Partial<DefaultTippyProps> = {
animation: "scale",
arrow: false,
ignoreAttributes: true,
interactive: false,
placement: "bottom",
duration: [100, 100],
};
tippy.setDefaultProps({ ...defaultProps });
export default {
created(el, binding) {
const props: Partial<TippyProps> = binding.value;
tippy(el, { ...props });
},
} as Directive<Element, Partial<TippyProps>>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment