Svelte Tooltip - Flowbite

Use the following Tailwind CSS powered tooltips to show extra content when hovering or focusing on an element

Flowbite-Svelte allows you to show extra information when hovering or focusing over an element in multiple positions, styles, and animations.


  import { Tooltip } from 'flowbite-svelte';

Default tooltip example

To get started with using tooltips all you need to do is set triggeredBy attribute of the tooltip component to any CSS query targeting trigger element(s). In the following example you can see the tooltip that will be trigger by the tooltip-default element to be shown when hovered or focused.

  import { Tooltip, Button } from 'flowbite-svelte';

<Button>Default tooltip</Button>
<Tooltip>Tooltip content</Tooltip>

Tooltip styles

You can use choose between dark and light version styles for the tooltip component by changing the utility classes from Tailwind CSS and by applying the style={light|dark} data attribute.

  import { Tooltip, Button } from 'flowbite-svelte';
  let style = 'dark';

<Button id="style-light">Light tooltip</Button>
<Button id="style-auto">Default tooltip</Button>
<Button id="style-dark">Dark tooltip</Button>
<Tooltip {style} triggeredBy="[id^='style-']" on:show={ev => style ='-')[1]}>Tooltip content</Tooltip>


The positioning of the tooltip element relative to the triggering element (eg. button, link) can be set using the placement={top|right|bottom|left} attribute.

Note! This examples shows you also how to share one tooltip between multiple triggering elements using advanced CSS query.

  import { Tooltip, Button } from 'flowbite-svelte';
  let placement = 'left';

<Button id="placement-left">Tooltip left</Button>
<Button id="placement-top">Tooltip top</Button>
<Button id="placement-bottom">Tooltip bottom</Button>
<Button id="placement-right">Tooltip right</Button>
<Tooltip triggeredBy="[id^='placement-']" {placement} on:show={(e)=> [, placement] ='-')}>
  Tooltip content - {placement}


  import { Tooltip, Button } from 'flowbite-svelte';

<Button id="hover">Tooltip hover</Button>
<Button id="click">Tooltip click</Button>
<Tooltip triggeredBy="#hover">Hover tooltip content</Tooltip>
<Tooltip trigger="click" triggeredBy="#click">Click tooltip content</Tooltip>

Disable arrow

  import { Tooltip, Button } from 'flowbite-svelte';

<Button id="disable-arrow">Default tooltip</Button>
<Tooltip arrow={false} triggeredBy='#disable-arrow'>Tooltip content</Tooltip>

Custom style

Various color palettes can be set for a tooltip by using the color property from the underlying Frame component. (Setting color prop sets the style to custom implicitly.)

When you want to add a fully custom styles, use style="custom", defaultClass, and class to modify the style.

  import { Tooltip, Button } from 'flowbite-svelte';

<Button>Green tooltip</Button>
<Tooltip  color="green">Tooltip content</Tooltip>

<Button>Yellow tooltip</Button>
<Tooltip  color="yellow">Tooltip content</Tooltip>

<Button>Custom style</Button>
  class="p-4 text-lg font-medium bg-purple-500 text-gray-100"
  Tooltip content



The component has the following props, type, and default values. See types page for type information.

Name Type Default
style 'dark' | 'light' | 'auto' | 'custom' 'dark'
defaultClass string 'py-2 px-3 text-sm font-medium'


The component inherits the following props, type, and default values from Frame. See types page for type information.

Name Type Default
tag string 'div'
color | 'gray' | 'red' | 'yellow' | 'green' | 'indigo' | 'default' | 'purple' | 'pink' | 'blue' | 'light' | 'dark' | 'dropdown' | 'navbar' | 'navbarUl' | 'form' | 'none' 'default'
rounded boolean false
border boolean false
shadow boolean false
transition TransitionFunc | undefined undefined
params object {}
node HTMLElement | undefined undefined
use Action noop
options object {}


Flowbite Tooltip