### Install SVooltip and Import Styles
Source: https://context7.com/gibbu/svooltip/llms.txt
Install the package using npm and import the directive and its default styles.
```bash
npm install svooltip
```
```svelte
```
--------------------------------
### Tooltip with Lifecycle Hooks (onMount, onDestroy)
Source: https://github.com/gibbu/svooltip/blob/main/src/routes/(site)/+page.md
Utilize `onMount` and `onDestroy` hook functions to trigger actions during the tooltip's lifecycle. This example demonstrates updating tooltip content dynamically after a delay and resetting it upon destruction.
```svelte
```
--------------------------------
### SVooltip Action with All Options
Source: https://context7.com/gibbu/svooltip/llms.txt
Demonstrates the extensive configuration options available for the `tooltip` action, including placement, delay, target, and custom classes.
```svelte
```
--------------------------------
### SVooltip Lifecycle Hooks (onMount, onDestroy)
Source: https://context7.com/gibbu/svooltip/llms.txt
Implement `onMount` and `onDestroy` callbacks to execute logic when the tooltip is added or removed from the DOM, useful for data loading or state synchronization.
```svelte
```
--------------------------------
### Svooltip Configuration Options
Source: https://github.com/gibbu/svooltip/blob/main/src/routes/(site)/+page.md
This table outlines the available properties for customizing the Svooltip component. Each property allows for specific adjustments to the tooltip's behavior and appearance.
```APIDOC
## Svooltip Configuration
### Description
Configuration options for the Svooltip component.
### Properties
- `content` (any) - Required - The content of the tooltip.
- `target` (string | HTMLElement)? - Optional - The target to append the tooltip to. Defaults to `body`.
- `placement` (Placement)? - Optional - The placement of the tooltip relative to the element. Defaults to `top`.
- `shiftPadding` (number)? - Optional - Padding for the `shift` middleware. Defaults to `5`.
- `offset` (number)? - Optional - The offset of the tooltip in `px`. Defaults to `10`.
- `delay` (number | [number, number])? - Optional - The delay for showing and hiding the tooltip. A number applies to both in and out. An array applies in and out delays separately. Defaults to `0`.
- `show` (boolean)? - Optional - Always display the tooltip. Defaults to `false`.
- `classes.container` (string)? - Optional - The classes to be applied on the tooltip itself. Defaults to `svooltip`.
- `classes.arrow` (string)? - Optional - The classes to be applied on the tooltip arrow. Defaults to `svooltip-arrow`.
- `classes.animationEnter` (string)? - Optional - The classes to be applied when the tooltip is entering. Defaults to `svooltip-entering`.
- `classes.animationLeave` (string)? - Optional - The classes to be applied when the tooltip is leaving. Defaults to `svooltip-leaving`.
- `middleware` (Middleware)? - Optional - Any Floating UI middleware you wish to add. Defaults to `[]`.
- `html` (boolean)? - Optional - What type of rendering to be used. Setting to `true` will use the element `innerHTML` rather than `textContent`. Defaults to `false`.
- `visibility` (boolean)? - Optional - Conditionally show the tooltip. Defaults to `true`.
```
--------------------------------
### Tooltip Placement with SVooltip
Source: https://context7.com/gibbu/svooltip/llms.txt
Configure tooltip positioning using Floating UI placement strings. The tooltip automatically flips and shifts to stay within the viewport.
```svelte
```
--------------------------------
### Basic Tooltip Usage in Svelte
Source: https://github.com/gibbu/svooltip/blob/main/README.md
Demonstrates how to import and use the `tooltip` directive in a Svelte component. Includes importing default styles and configuring tooltip content, placement, delay, offset, and target element.
```svelte
```
--------------------------------
### onMount
Source: https://github.com/gibbu/svooltip/blob/main/src/routes/(site)/+page.md
A function that fires when the tooltip has been mounted to the DOM.
```APIDOC
## onMount
### Description
A function that fires when the tooltip has been mounted to the DOM.
### Function Signature
`onMount`
### Parameters
This function does not accept any parameters.
### Return Value
This function does not return any value.
```
--------------------------------
### Basic SVooltip Action Usage
Source: https://context7.com/gibbu/svooltip/llms.txt
Use the `tooltip` action on an HTML element to display a simple tooltip on hover.
```svelte
```
--------------------------------
### Using the Tooltip Component
Source: https://github.com/gibbu/svooltip/blob/main/src/routes/(site)/+page.md
Import and use the `Tooltip` component directly if the Svelte `use` action is not suitable. Be aware of potential CSS selection and positioning issues due to the wrapper `div` and default `inline-block` styling. CSS variables are available for customization.
```svelte
Hover me
```
--------------------------------
### Tooltip Show/Hide Delay with SVooltip
Source: https://context7.com/gibbu/svooltip/llms.txt
Set custom delays for tooltip appearance and disappearance using a number for uniform delay or a tuple for independent show/hide delays in milliseconds.
```svelte
```
--------------------------------
### Custom Floating UI Middleware for Tooltip
Source: https://context7.com/gibbu/svooltip/llms.txt
Extend tooltip positioning behavior by passing custom Floating UI middleware. Built-in middleware like `flip`, `shift`, `offset`, and `arrow` are always included.
```svelte
```
--------------------------------
### Basic Tooltip Wrapper Component
Source: https://context7.com/gibbu/svooltip/llms.txt
Use the Tooltip component as a wrapper for other Svelte components when `use:` directives are not applicable. It accepts standard tooltip options plus `block` and `as` props.
```svelte
Hover meFull-width hoverHover
```
--------------------------------
### CSS Custom Properties for Theming
Source: https://context7.com/gibbu/svooltip/llms.txt
Customize tooltip appearance at runtime using CSS custom properties. These have lower priority than SCSS variables.
```css
/* CSS custom properties (runtime, lower priority than SCSS vars) */
:root {
--svooltip-bg: #444;
--svooltip-text: #fff;
--svooltip-padding: 4px 8px;
--svooltip-roundness: 4px;
--svooltip-weight: 500;
--svooltip-text-size: 0.875rem;
--svooltip-shadow: 0 2px 5px rgb(0 0 0 / 0.35);
--svooltip-arrow-size: 12px;
--svooltip-animation-duration: 0.15s;
--svooltip-index: 1;
}
```
--------------------------------
### Tooltip with HTML Content
Source: https://github.com/gibbu/svooltip/blob/main/src/routes/(site)/+page.md
Enable HTML content within the tooltip by setting the `html` option to `true`. Remember to sanitize any user-generated content before displaying it.
```svelte
```
--------------------------------
### Dynamic Tooltip Content with Reactivity
Source: https://context7.com/gibbu/svooltip/llms.txt
The tooltip content can be reactive. Update the bound variable, and the tooltip will automatically re-render using the action's `update()` hook.
```svelte
```
--------------------------------
### Always-Visible Tooltip with SVooltip
Source: https://context7.com/gibbu/svooltip/llms.txt
Enable a persistent tooltip using the `constant: true` option, which keeps the tooltip visible immediately on mount and prevents it from hiding.
```svelte
```
--------------------------------
### CSS Animations for Tooltip
Source: https://github.com/gibbu/svooltip/blob/main/src/routes/(site)/+page.md
Animate tooltips using CSS `@keyframes` by targeting the `animationEnter` and `animationLeave` classes. The default styling includes `scaleIn` and `scaleOut` animations. Using keyframes allows for `animationend` event listeners to manage DOM removal.
```css
.svooltip-entering {
animation: scaleIn 0.15s ease forwards;
}
.svooltip-leaving {
animation: scaleOut 0.15s ease forwards;
}
@keyframes scaleIn {
from {
transform: scale(0.95);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}
}
@keyframes scaleOut {
from {
transform: scale(1);
opacity: 1;
}
to {
transform: scale(0.95);
opacity: 0;
}
}
```
--------------------------------
### SCSS Variables for Compile-Time Customization
Source: https://context7.com/gibbu/svooltip/llms.txt
Customize tooltip appearance at compile time using SCSS variables. This provides the highest priority for theming.
```scss
// SCSS variables (compile-time, highest priority)
// In your global