| Install | |
|---|---|
composer require mrshanebarron/tooltip |
|
| Latest Version: | v1.0.7 |
| PHP: | ^8.1 |
A lightweight tooltip component for Laravel applications. Displays helpful hints on hover or click. Works with Livewire and Vue 3.
composer require mrshanebarron/tooltip
<livewire:sb-tooltip content="This is a tooltip">
<button>Hover me</button>
</livewire:sb-tooltip>
<livewire:sb-tooltip content="Top tooltip" position="top">
<button>Top</button>
</livewire:sb-tooltip>
<livewire:sb-tooltip content="Bottom tooltip" position="bottom">
<button>Bottom</button>
</livewire:sb-tooltip>
<livewire:sb-tooltip content="Left tooltip" position="left">
<button>Left</button>
</livewire:sb-tooltip>
<livewire:sb-tooltip content="Right tooltip" position="right">
<button>Right</button>
</livewire:sb-tooltip>
<livewire:sb-tooltip content="Click to see this" trigger="click">
<button>Click me</button>
</livewire:sb-tooltip>
| Prop | Type | Default | Description |
|---|---|---|---|
content |
string | '' |
Tooltip text |
position |
string | 'top' |
Position: top, bottom, left, right |
trigger |
string | 'hover' |
Trigger: hover or click |
import { SbTooltip } from './vendor/sb-tooltip';
app.component('SbTooltip', SbTooltip);
<template>
<SbTooltip content="This is helpful information">
<button>Hover for help</button>
</SbTooltip>
</template>
<template>
<SbTooltip content="Top tooltip" position="top">
<button>Top</button>
</SbTooltip>
<SbTooltip content="Bottom tooltip" position="bottom">
<button>Bottom</button>
</SbTooltip>
<SbTooltip content="Left tooltip" position="left">
<button>Left</button>
</SbTooltip>
<SbTooltip content="Right tooltip" position="right">
<button>Right</button>
</SbTooltip>
</template>
<template>
<SbTooltip content="Copied!" trigger="click">
<button @click="copyText">Copy to clipboard</button>
</SbTooltip>
</template>
<template>
<div class="flex gap-2">
<SbTooltip content="Edit">
<button class="p-2 hover:bg-gray-100 rounded">
<EditIcon />
</button>
</SbTooltip>
<SbTooltip content="Delete">
<button class="p-2 hover:bg-gray-100 rounded">
<TrashIcon />
</button>
</SbTooltip>
<SbTooltip content="Share">
<button class="p-2 hover:bg-gray-100 rounded">
<ShareIcon />
</button>
</SbTooltip>
</div>
</template>
<template>
<div class="flex items-center gap-2">
<label>API Key</label>
<SbTooltip content="Your API key can be found in Settings > Developer">
<svg class="w-4 h-4 text-gray-400 cursor-help">
<!-- Help icon -->
</svg>
</SbTooltip>
</div>
<input type="text" v-model="apiKey" />
</template>
| Prop | Type | Default | Description |
|---|---|---|---|
content |
String | '' |
Tooltip text content |
position |
String | 'top' |
Position: top, bottom, left, right |
trigger |
String | 'hover' |
How to show: hover or click |
Uses Tailwind CSS:
Tooltips provide supplementary information. For critical information, ensure it's also available through other means.
MIT License