Tooltip文字提示 - 图1

Tooltip 工具提示

基本用法

  1. import { Tooltip, Cell, Button, Message, Icon } from 'zarm';
  2. const Demo = () => (
  3. <>
  4. <Cell>
  5. <div>
  6. <div style={{ marginLeft: 60 }}>
  7. <Tooltip direction="topLeft" content="topLeft text">
  8. <Button block size="xs">TL</Button>
  9. </Tooltip>
  10. <Tooltip direction="top" content="top text">
  11. <Button block size="xs">Top</Button>
  12. </Tooltip>
  13. <Tooltip direction="topRight" content="topRight text">
  14. <Button block size="xs">TR</Button>
  15. </Tooltip>
  16. </div>
  17. <div style={{ width: 60, float: 'left', clear: 'both' }}>
  18. <Tooltip direction="leftTop" content="leftTop text">
  19. <Button block size="xs">LT</Button>
  20. </Tooltip>
  21. <Tooltip direction="left" content="left text">
  22. <Button block size="xs">Left</Button>
  23. </Tooltip>
  24. <Tooltip direction="leftBottom" content="leftBottom text">
  25. <Button block size="xs">LB</Button>
  26. </Tooltip>
  27. </div>
  28. <div style={{ width: 60, marginLeft: 60 * 4 + 20 }}>
  29. <Tooltip direction="rightTop" content="rightTop text">
  30. <Button block size="xs">RT</Button>
  31. </Tooltip>
  32. <Tooltip direction="right" content="right text">
  33. <Button block size="xs">Right</Button>
  34. </Tooltip>
  35. <Tooltip direction="rightBottom" content="rightBottom text">
  36. <Button block size="xs">RB</Button>
  37. </Tooltip>
  38. </div>
  39. <div style={{ marginLeft: 60, clear: 'both' }}>
  40. <Tooltip direction="bottomLeft" content="bottomLeft text">
  41. <Button block size="xs">BL</Button>
  42. </Tooltip>
  43. <Tooltip direction="bottom" content="bottom text">
  44. <Button block size="xs">Bottom</Button>
  45. </Tooltip>
  46. <Tooltip direction="bottomRight" content="bottomRight text">
  47. <Button block size="xs">BR</Button>
  48. </Tooltip>
  49. </div>
  50. <Message theme="warning" icon={<Icon type="warning-round" />}>左右两侧显示位置不足会自动调整为反向显示</Message>
  51. </div>
  52. </Cell>
  53. </>
  54. );
  55. ReactDOM.render(<Demo />, mountNode);

API

属性类型默认值说明
visiblebooleanfalse是否显示
contentReactNode-显示内容
hasArrowbooleanfalse是否带有箭头
arrowPointAtCenterbooleanfalse箭头是否指向目标元素中心
classNamestring-气泡层类名追加
mouseEnterDelaynumber100鼠标移入后延时多少才显示气泡层,单位:毫秒
mouseLeaveDelaynumber100鼠标移出后延时多少才隐藏气泡层,单位:毫秒
directionstring'top'显示方向,可选值 topLefttoptopRightrightToprightrightBottombottomLeftbottombottomRightleftTopleftleftBottom
triggerstring'click'触发方式,PC端默认值为 'hover', 可选值为:点击触发click、hover状态触发hover、聚焦状态触发focus、受控触发manual、右键触发contextMenu
onVisibleChange(visible?: boolean) => voidnoop显示/隐藏触发的事件