2.19.6 • Published 6 years ago

evergreen-tooltip v2.19.6

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Tooltip

evergreen-tooltip is a package exporting a Tooltip React component. Tooltips display floating content in relation to a target. Tooltip appear either at the top, bottom of their target. The preferred and default side is the bottom.

Design example

tooltip

Implementation details

  • Uses Positioner from evergreen-positioner
  • Tooltips use onMouseLeave and onMouseEnter to show and hide the tooltip
  • Tooltips use a similar implementation to Popovers,

When creating a popover, you must specify both:

  • its content, by setting the content prop, and
  • its target, as a single child element or a function

Usage

<Tooltip content="My tooltip content. Lorem ipsum dolar set amet.">
  <Text display="inline-block" cursor="help">
    Hover to trigger
  </Text>
</Tooltip>

Prop types

static propTypes = {
  ...Positioner.propTypes,
  content: PropTypes.node,
  isShown: PropTypes.bool,
  children: PropTypes.node,
  tooltipProps: PropTypes.object,
  statelessProps: PropTypes.objectOf(TooltipStateless.propTypes),
}

Complete Story

import { storiesOf } from '@storybook/react'
import React from 'react'
import Box from 'ui-box'
import { Text } from 'evergreen-typography'
import { Tooltip } from '../src/'

storiesOf('tooltip', module).add('Tooltip', () => (
  <Box padding={40}>
    {(() => {
      document.body.style.margin = '0'
      document.body.style.height = '100vh'
    })()}
    <Tooltip content="My tooltip content. Lorem ipsum dolar set amet.">
      <Text display="inline-block" cursor="help">
        Hover to trigger
      </Text>
    </Tooltip>
    <Tooltip content="My tooltip content">
      <Text marginLeft={40} display="inline-block" cursor="help">
        Hover to trigger
      </Text>
    </Tooltip>
  </Box>
))
2.19.6

6 years ago

2.19.5

6 years ago

2.19.4

6 years ago

2.19.3

6 years ago

2.19.2

6 years ago

2.19.0

6 years ago

2.18.20

6 years ago

2.18.17

6 years ago

2.18.16

6 years ago

2.18.14

6 years ago

2.18.6

7 years ago

2.16.0

7 years ago

2.13.0

7 years ago

2.10.0

7 years ago

2.9.1

7 years ago

2.9.0

7 years ago

2.5.0

7 years ago