tooltips.mdx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ---
  2. title: Tooltips
  3. summary: Tooltips are text labels which appear when a user hovers over an interface element. They explain the interface elements that may be unclear for users and guide them when they need help. If used properly, tooltips can significantly enhance user experience and add value to your website or software.
  4. bootstrapLink: components/tooltips/
  5. description: Guide users with informative tooltips.
  6. ---
  7. ## Default markup
  8. Use the default markup to create tooltips that will help users understand particular elements of your interface. You can decide where the text label is to be displayed - at the top, bottom or on either side of the element.
  9. ```html example centered separated
  10. <button
  11. type="button"
  12. class="btn"
  13. data-bs-toggle="tooltip"
  14. data-bs-placement="top"
  15. title="Tooltip on top"
  16. >
  17. Tooltip on top
  18. </button>
  19. <button
  20. type="button"
  21. class="btn"
  22. data-bs-toggle="tooltip"
  23. data-bs-placement="right"
  24. title="Tooltip on right"
  25. >
  26. Tooltip on right
  27. </button>
  28. <button
  29. type="button"
  30. class="btn"
  31. data-bs-toggle="tooltip"
  32. data-bs-placement="bottom"
  33. title="Tooltip on bottom"
  34. >
  35. Tooltip on bottom
  36. </button>
  37. <button
  38. type="button"
  39. class="btn"
  40. data-bs-toggle="tooltip"
  41. data-bs-placement="left"
  42. title="Tooltip on left"
  43. >
  44. Tooltip on left
  45. </button>
  46. ```
  47. ## Tooltip with HTML
  48. If the default tooltip is not enough, you can add the option to use HTML code in the text to highlight particular bits of information and make the content more attractive.
  49. ```html example height="7rem"
  50. <button
  51. type="button"
  52. class="btn"
  53. data-bs-toggle="tooltip"
  54. data-bs-html="true"
  55. title="<em>Tooltip</em> <u>with</u> <b>HTML</b>"
  56. >
  57. Tooltip with HTML
  58. </button>
  59. ```