Tooltip
Documentation for the <Tooltip />
component. Learn about the available props and how to use it.
Installation
To get started, install @exponentialeducation/tooltip
via yarn
:
# Yarn
yarn add @exponentialeducation/tooltip
Basic Example
Tooltip
use it for showing additional information during hover interactions.
{/* ... */}
import { Tooltip } from '@exponentialeducation/tooltip';
function IndexPage() { return ( <main> {/* ... */}
<div className="mt-5 text-center"> Inline text can have <Tooltip placement="top" content="Tooltip content"> <span className="cursor-default italic border-primary-500 border-b-2 border-dashed"> a tooltip </span> </Tooltip> </div>
{/* ... */} </main> )}
Placements
You can change the tooltip placement
(see the placement prop to see all the valid options)
{/* ... */}
import { Tooltip } from '@exponentialeducation/tooltip';
function IndexPage() { return ( <main> {/* ... */}
<Tooltip placement="left" content="Tooltip content"> <span className="cursor-default border-primary-500 border-b-2 border-dashed"> Available </span> </Tooltip> <Tooltip placement="top" content="Tooltip content"> <span className="cursor-default border-primary-500 border-b-2 border-dashed"> in the full </span> </Tooltip> <Tooltip placement="bottom" content="Tooltip content"> <span className="cursor-default border-primary-500 border-b-2 border-dashed"> range of </span> </Tooltip> <Tooltip placement="right" content="Tooltip content"> <span className="cursor-default border-primary-500 border-b-2 border-dashed"> visual intents </span> </Tooltip>
{/* ... */} </main> )}
Disabled
import { Tooltip } from '@exponentialeducation/tooltip';
function IndexPage() { return ( <div className="w-full mt-5"> {/* ... */}
<div className="mt-5 text-center"> This line's tooltip <Tooltip disabled placement="top" content="Tooltip content"> <span className="cursor-default italic border-primary-500 border-b-2 border-dashed"> is disabled </span> </Tooltip> </div>
{/* ... */} </div> );}
Props
prop | description |
---|---|
children |
|
content |
|
disabled? |
|
gap? |
|
placement? |
|