Petunjuk Alat Bootstrap 5

Tooltip

Komponen tooltip adalah kotak pop-up kecil yang muncul saat pengguna memindahkan penanda mouse ke elemen:

Bagaimana Membuat Tooltip

Untuk membuat tooltip, silakan gunakan data-bs-toggle="tooltip" ditambahkan ke elemen.

Use title Atribut menentukan teks yang ditampilkan di tooltip:

<button type="button" class="btn btn-primary" data-bs-toggle="tooltip" title="Sangat Menarik!">Tunggu Di Atas Saya!</button>

Note:Tooltips must be initialized with JavaScript to work.

The following code will enable all tooltips in the document:

<script>
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
  return new bootstrap.Tooltip(tooltipTriggerEl)
}
</script>

Try It Yourself

Positioning the Tooltip

By default, the tooltip will appear at the top of the element.

Use data-bs-placement Set the position of the tooltip on the top, bottom, left, or right of the element:

Examples

<a href="#" data-bs-toggle="tooltip" data-bs-placement="top" title="Great!">Hover</a>
<a href="#" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Great!">Hover</a>
<a href="#" data-bs-toggle="tooltip" data-bs-placement="left" title="Great!">Hover</a>
<a href="#" data-bs-toggle="tooltip" data-bs-placement="right" title="Great!">Hover</a>

Try It Yourself