@s-ui/react-atom-tooltip

2.7.0 • Public • Published

AtomTooltip

AtomTooltip is a component that wraps an element and shows a tooltip over it. It has some properties like:

  • it will show the title attribute of the wrapped element by default
  • can also display html as content of the tooltip
  • being displayed on the screen changing sides if necessary
  • being displayed on target focus (through keyboard)
  • delays can be set
  • the arrow position can be set
  • options to select text on tooltip
  • tooltip will be hidden if targeted element is not in the viewport
  • tooltip can be applied over buttons (or any element w/ onClick)

General behaviour will be:

  • Desktop (Non-touch devices) → tooltip will be displayed only on mouseover
  • Mobile (Touch devices) → tooltip will be displayed on touch over target element and hidden w/ another touch outside of it

Installation

$ npm install @s-ui/react-atom-tooltip --save

Usage

After importing the component AtomTooltip like this

import AtomTooltip from '@s-ui/react-atom-tooltip'

Basic usage

<AtomTooltip content="Last month of the year">
  <strong>december</strong>
</AtomTooltip>

HTML in the Tooltip

<AtomTooltip
  content={
    <div>
      Hello <strong>world</strong>!
    </div>
  }
>
  <strong>december</strong>
</AtomTooltip>

Without arrow

<AtomTooltip isArrowed={false} content="Last month of the year">
  <strong>december</strong>
</AtomTooltip>

With delay on show and/or hide

<AtomTooltip delay={{show: 300, hide: 1500}} content="Last month of the year">
  <strong>december</strong>
</AtomTooltip>

Selecting arrow position

<AtomTooltip
  placement={atomTooltipPlacements.TOP_START}
  content="Last month of the year"
>
  <strong>december</strong>
</AtomTooltip>

Tooltip on a "call to action" element

<AtomTooltip content="This menu display some cool options">
  <button onClick={() => alert('👍  displaying menú')}>Menu options</button>
</AtomTooltip>

Find full description and more examples in the demo page.

Readme

Keywords

none

Package Sidebar

Install

npm i @s-ui/react-atom-tooltip

Weekly Downloads

2,754

Version

2.7.0

License

MIT

Unpacked Size

14 kB

Total Files

9

Last publish

Collaborators

  • daniel.perez.ext
  • albert.peiro
  • frandelacasa-adevinta
  • mariapaula.forero.ext
  • hpintos_adevinta
  • sziauberyte
  • victor.perez.adevinta
  • oscar-raig-adevinta
  • carlos.gonzalezl
  • carolina.mallo.ext
  • david.nieto
  • ferran.simon
  • xavi_conejo
  • sergi.quintela
  • jamile.radloff
  • xavi_ballestar
  • luz_adv
  • ignacio.rodriguez
  • carlosvillu-adevinta
  • diegomr
  • arturo.vicente
  • adria.velardos
  • emiliovz
  • dann41
  • ruben-martin
  • pol.valls
  • cristina.rodriguez.duque
  • sergio.escano
  • marc.benito
  • azahara
  • patricio.sartore
  • giovanny.sayas.ext
  • david.cuadrado.ext
  • alex.castells
  • beatrizip
  • pablo.rey-adevinta
  • sergiocollado
  • mango.sanchezredondo
  • cristhianb
  • alisa_bayanova
  • davidmartin2108
  • ferrangbtw
  • estefania_garcia
  • belen.santos
  • alfredo.arronte
  • joanleon-adv
  • giodelabarrera.adevinta
  • luis-garrido
  • aitor.rodriguez
  • jordi.munoz
  • oscar_ramirez
  • ignacio_navarro
  • a.ferrer
  • gfabregoadv
  • izeller
  • salvador.juan
  • oriol.egea
  • ivanmlaborda
  • alejandro.ferrante
  • pa.chruscinski.ext
  • isabelgomez87
  • jenifer.lopez
  • daniela.aguilera
  • pablogs
  • javier.miguel
  • oscar.gomez
  • marian.lucaci
  • alverd004
  • oriol.puig
  • nacho_torrella
  • xavi.murcia
  • chloe.leteinturier
  • javiauso
  • alfredo.zimperz
  • francisco.ruiz.lloret
  • fermin.adevinta
  • andresadv
  • schibstedspain