Tooltip
Basic usage
Hover (default)
Hi, there
<p>Hover (default)</p>
<CTooltip content="Hi, there">
<CButton slot="trigger" label="Hover Me" />
</CTooltip>
<p>Hover (default)</p>
<CTooltip content="Hi, there">
<CButton slot="trigger" label="Hover Me" />
</CTooltip>
svelte
Click fold/expand code
Trigger
Hover (default)
Hi, there
Click
Hi, there
Manual
Click the left button to toggle
Hi, there
<script lang="ts">
let show = false
</script>
<p>Hover (default)</p>
<CTooltip content="Hi, there">
<CButton slot="trigger" label="Hover Me" />
</CTooltip>
<p>Click</p>
<CTooltip content="Hi, there" trigger="click">
<CButton label="Click Me" slot="trigger" />
</CTooltip>
<p>Manual</p>
<CButton label="Click Me" on:click={() => (show = !show)} />
<CTooltip bind:show content="Hi, there" trigger="manual">
<p slot="trigger">Click the left button to toggle</p>
</CTooltip>
<script lang="ts">
let show = false
</script>
<p>Hover (default)</p>
<CTooltip content="Hi, there">
<CButton slot="trigger" label="Hover Me" />
</CTooltip>
<p>Click</p>
<CTooltip content="Hi, there" trigger="click">
<CButton label="Click Me" slot="trigger" />
</CTooltip>
<p>Manual</p>
<CButton label="Click Me" on:click={() => (show = !show)} />
<CTooltip bind:show content="Hi, there" trigger="manual">
<p slot="trigger">Click the left button to toggle</p>
</CTooltip>
svelte
Click fold/expand code
Positions
top-start
top
top-end
left-start
left
left-end
right-start
right
right-end
bottom-start
bottom
bottom-end
Hi, I'm some message from top!
<script lang="ts">
let position = 'top'
const positions: any = [
'top-start',
'top',
'top-end',
'left-start',
'left',
'left-end',
'right-start',
'right',
'right-end',
'bottom-start',
'bottom',
'bottom-end',
]
</script>
<div class="grid grid-cols-3 gap-4">
<CRadioGroup bind:value={position} options="{positions.map(pos => ({ label: pos, value: pos }))}" />
<CTooltip {position} content={`Hi, I'm some message from ${position}!`}>
<CButton label="Hover me to see the effect" slot="trigger" />
</CTooltip>
</div>
<script lang="ts">
let position = 'top'
const positions: any = [
'top-start',
'top',
'top-end',
'left-start',
'left',
'left-end',
'right-start',
'right',
'right-end',
'bottom-start',
'bottom',
'bottom-end',
]
</script>
<div class="grid grid-cols-3 gap-4">
<CRadioGroup bind:value={position} options="{positions.map(pos => ({ label: pos, value: pos }))}" />
<CTooltip {position} content={`Hi, I'm some message from ${position}!`}>
<CButton label="Hover me to see the effect" slot="trigger" />
</CTooltip>
</div>
svelte
Click fold/expand code
CTooltip Props
- contentdefault:
string
The content text of tooltip
- positiondefault:
string
top
The tooltip popup position
- triggerdefault:
'hover' | 'click' | 'manual'
hover
The trigger method
- showdefault:
boolean
false
Determine the tooltip content is shown or not. Usful when the trigger method is set to 'manual'
CTooltip Events
No data
CTooltip Slots
- trigger
The trigger content
- default
The tooltip content. Notice that this slot will override the content prop
CTooltip Exports
No data