Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tippyjs plugin to use `textContent` of the child as content.
import type { Props, Plugin, LifecycleHooks } from 'tippy.js';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface CustomProps {}
type FilteredProps = CustomProps &
Omit<Props, keyof CustomProps | keyof LifecycleHooks>;
type ExtendedProps = FilteredProps & LifecycleHooks<FilteredProps>;
const textContent: Plugin<ExtendedProps> = {
// Required
fn(instance) {
return {
onShow() {
instance.setProps({
content: instance.reference.textContent ?? undefined,
});
},
};
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment