Basic example
Popovers are overlays that open on demand and is mainly used on elements to display more content on floating card popped by clicking or hovering.
<button type="button" class="inline-block rounded bg-danger px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-danger-3 transition duration-150 ease-in-out hover:bg-danger-accent-300 hover:shadow-danger-2 focus:bg-danger-accent-300 focus:shadow-danger-2 focus:outline-none focus:ring-0 active:bg-danger-600 active:shadow-danger-2 motion-reduce:transition-none dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong" data-twe-toggle="popover" data-twe-title="Popover title" data-twe-content="And here's some amazing content. It's very engaging. Right?" data-twe-ripple-init data-twe-ripple-color="light"> Click to toggle popover </button> // Initialization for ES Users import { Popover, Ripple, initTWE, } from "tw-elements"; initTWE({ Popover, Ripple }); Four directions
Four options are available: top, right, bottom, and left aligned.
<button type="button" class="inline-block rounded bg-primary-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-primary-700 transition duration-150 ease-in-out hover:bg-primary-accent-200 focus:bg-primary-accent-200 focus:outline-none focus:ring-0 active:bg-primary-accent-200 motion-reduce:transition-none dark:bg-primary-300 dark:hover:bg-primary-400 dark:focus:bg-primary-400 dark:active:bg-primary-400" data-twe-toggle="popover" data-twe-placement="top" data-twe-content="Top popover" data-twe-ripple-init data-twe-ripple-color="light"> Popover on top </button> <button type="button" class="inline-block rounded bg-primary-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-primary-700 transition duration-150 ease-in-out hover:bg-primary-accent-200 focus:bg-primary-accent-200 focus:outline-none focus:ring-0 active:bg-primary-accent-200 motion-reduce:transition-none dark:bg-primary-300 dark:hover:bg-primary-400 dark:focus:bg-primary-400 dark:active:bg-primary-400" data-twe-toggle="popover" data-twe-placement="right" data-twe-content="Right popover" data-twe-ripple-init data-twe-ripple-color="light"> Popover on right </button> <button type="button" class="inline-block rounded bg-primary-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-primary-700 transition duration-150 ease-in-out hover:bg-primary-accent-200 focus:bg-primary-accent-200 focus:outline-none focus:ring-0 active:bg-primary-accent-200 motion-reduce:transition-none dark:bg-primary-300 dark:hover:bg-primary-400 dark:focus:bg-primary-400 dark:active:bg-primary-400" data-twe-toggle="popover" data-twe-placement="bottom" data-twe-content="Bottom popover" data-twe-ripple-init data-twe-ripple-color="light"> Popover on bottom </button> <button type="button" class="inline-block rounded bg-primary-100 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-primary-700 transition duration-150 ease-in-out hover:bg-primary-accent-200 focus:bg-primary-accent-200 focus:outline-none focus:ring-0 active:bg-primary-accent-200 motion-reduce:transition-none dark:bg-primary-300 dark:hover:bg-primary-400 dark:focus:bg-primary-400 dark:active:bg-primary-400" data-twe-toggle="popover" data-twe-placement="left" data-twe-content="Left popover" data-twe-ripple-init data-twe-ripple-color="light"> Popover on left </button> // Initialization for ES Users import { Popover, Ripple, initTWE, } from "tw-elements"; initTWE({ Popover, Ripple }); Dismiss on next click
Use the focus trigger to dismiss popovers on the user next click of a different element than the toggle element.
<a tabindex="0" class="inline-block rounded bg-danger px-7 pb-2.5 pt-3 text-sm font-medium uppercase leading-normal text-white shadow-danger-3 transition duration-150 ease-in-out hover:bg-danger-accent-300 hover:shadow-danger-2 focus:bg-danger-accent-300 focus:shadow-danger-2 focus:outline-none focus:ring-0 active:bg-danger-600 active:shadow-danger-2 motion-reduce:transition-none dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong" role="button" data-twe-toggle="popover" data-twe-trigger="focus" title="Dismissible popover" data-twe-content="And here's some amazing content. It's very engaging. Right?" data-twe-ripple-init data-twe-ripple-color="light" >Dismissible popover</a > // Initialization for ES Users import { Popover, Ripple, initTWE, } from "tw-elements"; initTWE({ Popover, Ripple }); Disabled
Elements with the disabled attribute aren’t interactive, meaning users cannot hover or click them to trigger a popover.
<span class="inline-block focus:outline-none" tabindex="0" data-twe-toggle="popover" data-twe-trigger="hover focus" data-twe-content="Disabled popover"> <button class="pointer-events-none rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white opacity-60 shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-0 focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong" type="button" disabled> Disabled button </button> </span> // Initialization for ES Users import { Popover, Ripple, initTWE, } from "tw-elements"; initTWE({ Popover, Ripple }); Related resources
Tutorials:
Extended Docs:
animations colors hover effects images alerts badges buttons collapse dropdown modal notifications social buttons tooltip charts box sizing center text colors dark theme display flex position spacing text bold text color visibility hidden z index