Floating label used to clarify interface actions
CdrTooltip is a wrapper component that accepts a trigger element and tooltip content. When the trigger element is hovered or focused, the tooltip content is rendered. Event bindings between the trigger and the tooltip are set up automatically. The tooltip will dynamically update its position
property to ensure that it renders on screen, though this functionality can be disabled by setting autoPosition
to false
.
CdrTooltip can also be controlled programmatically using the open
prop. However, doing so means that you must implement certain behavior yourself:
position: relative
and width: max-content
.open
property should be toggled to true on mouseover
and focus
, and toggled to false on blur
and focus
.aria-describedby
property set to the ID of the CdrTooltip.To ensure your usage of this component complies with accessibility guidelines you are responsible for the following:
id
property on the CdrTooltip. The component will automatically link that id
to the trigger element.trigger
slot must be an actionable element such as a button.This component complies with WCAG guidelines by:
aria-described-by
on the trigger element to point to the id of the tooltip.role="tooltip"
to the tooltip content.esc
key.When an interface action is expressed solely through iconography, use a tooltip to clarify the action. Only interactive elements should trigger tooltips. The descriptions provided by tooltips should only contain one or two words: “close”, “clear”, or “save” are common examples.
Examples:
Example:
id
name
string
type
default
Id for the CdrTooltip element. Required for accessibility.
position
name
string
type
'top'
default
Sets the position where the tooltip will render relative to the trigger element. Possible values: 'top' | 'bottom' | 'left' | 'right'
autoPosition
name
boolean
type
true
default
If set to `true`, tooltip will attempt to dynamically set it's position to ensure it renders within the visible browser window. If `false` the tooltip will always render in the provided `position`.
contentClass
name
string
type
default
Adds a custom class to the tooltip content wrapper. Allows for overriding it's size, styling, etc.
open
name
boolean
type
default
Used to programmatically control the tooltip state. Does not need to be set if you are using the `trigger` slot. See the Custom Trigger examples for more info.
Find more information about using Slots in the article Installing Cedar.
default
name
Slot for CdrTooltip content.
trigger
name
Slot for the element that triggers the tooltip. Element should be a button and must be the first and only child of this slot. Event handlers are bound to this element automatically.
closed
name
$emit event fired when tooltip is closed.
opened
name
$emit event fired when tooltip is opened.