Tooltip
Tooltip
Component demo
Interactive example
<ic-tooltiptarget="test-button-0"label="Add Americano to favourites"placement="top"><ic-buttonid="test-button-0"aria-describedby="ic-tooltip-test-button-0"> Add</ic-button></ic-tooltip><ic-tooltiptarget="test-button-1"label="Remove Americano from favourites"placement="bottom"><ic-buttonid="test-button-1"aria-describedby="ic-tooltip-test-button-1"> Remove</ic-button></ic-tooltip>
Tooltip details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
|
|---|---|---|
|
|
The text to display on the tooltip. |
|
|
|
If |
|
|
|
If |
|
|
|
Setting to |
|
|
|
The alt text to be used alongside a slotted icon. |
|
|
|
The number of lines to display before truncating the text. |
|
|
|
The position of the tooltip in relation to the parent element. |
|
|
|
The ID of the element the tooltip is describing - for when aria-labelledby or aria-describedby is used. |
|
|
|
Sets the tooltip to the dark or light theme colors. "inherit" will set the color based on the system settings or ic-theme component. |
|
|
The text to display on the tooltip. |
|
If |
|
If |
|
Setting to |
|
The alt text to be used alongside a slotted icon. |
|
The number of lines to display before truncating the text. |
|
The position of the tooltip in relation to the parent element. |
|
The ID of the element the tooltip is describing - for when aria-labelledby or aria-describedby is used. |
|
Sets the tooltip to the dark or light theme colors. "inherit" will set the color based on the system settings or ic-theme component. |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
|
|---|---|
|
|
|
|
|
CSS Custom Properties
|
|
|
|---|---|
|
|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
|
|---|---|---|
|
|
|
|
|
|
Methods
|
|
|
|
|---|---|---|
|
|
|
|
|
|
Variants
Left placement
Interactive example
<ic-tooltiptarget="test-button"label="Add Americano to favourites"placement="left"><ic-buttonid="test-button"aria-describedby="ic-tooltip-test-button"> Add</ic-button></ic-tooltip>
Right placement
Interactive example
<ic-tooltiptarget="test-button"label="Add Americano to favourites"placement="right"><ic-buttonid="test-button"aria-describedby="ic-tooltip-test-button">Add</ic-button></ic-tooltip>
Chip
Interactive example
<ic-tooltiptarget="small-chip"label="An espresso-based drink"><ic-chipid="small-chip"label="Americano"size="small"><svgslot="icon"width="24"height="24"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg></ic-chip></ic-tooltip>
Programmatic trigger
Interactive example
<ic-buttonid="clickMe">Show tooltip</ic-button><ic-tooltipid="targetTooltip"label="Add Americano to favourites"target="test-button"><ic-buttonid="test-button"aria-describedby="ic-tooltip-test-button"> Add</ic-button></ic-tooltip>