Constructor
JavaScript:
-
new Coral.Tooltip()
ordocument.createElement('coral-tooltip')
HTML Tag:
-
<coral-tooltip>
Extends
Sub-components
Static Properties
-
Coral.Tooltip.interaction {String}
-
Properties:
Name Type Value Description ON String on Show when the target is hovered or focused and hide when the mouse is moved out or focus is lost. OFF String off Do not show or hide automatically. -
Coral.Tooltip.variant {String}
-
Properties:
Name Type Value Description INFO String info A blue tooltip that informs the user of non-critical information. ERROR String error A red tooltip that indicates an error has occurred. WARNING String warning An orange tooltip that notifies the user of something important. SUCCESS String success A green tooltip that indicates an operation was successful. INSPECT String inspect A dark gray tooltip that provides additional information for a chart item.
Tooltip interaction values.
Tooltip variants.
Instance Properties
-
instance.alignAt {Coral.Overlay.align}
-
- Default Value:
- Coral.Overlay.align.RIGHT_CENTER
- HTML Attribute:
- alignat
-
instance.alignMy {Coral.Overlay.align}
-
- Default Value:
- Coral.Overlay.align.LEFT_CENTER
- HTML Attribute:
- alignmy
-
instance.collision {Coral.Overlay.collision}
-
- Inherited From:
- Default Value:
- Coral.Overlay.collision.FLIP_FIT
- HTML Attribute:
- collision
-
instance.content {HTMLElement}
-
-
instance.delay {Number}
-
- Default Value:
- 500
- HTML Attribute:
- delay
-
instance.focusOnShow {Coral.mixin.overlay.focusOnShow | HTMLElement | String}
-
- Default Value:
- Coral.mixin.overlay.focusOnShow.ON
- HTML Attribute:
- focusonshow
-
instance.focusOnShow {Coral.mixin.overlay.focusOnShow | HTMLElement | String}
-
- Default Value:
- HTML Attribute:
- focusonshow
-
instance.hidden {Boolean}
Reflected -
- Inherited From:
- Default Value:
- false
- HTML Attribute:
- hidden
-
instance.interaction {Coral.Tooltip.interaction}
-
- Default Value:
- Coral.Tooltip.interaction.ON
- HTML Attribute:
- interaction
-
instance.offset {Number}
-
- Default Value:
- 5
- HTML Attribute:
- offset
-
instance.open {Boolean}
Reflected -
- Default Value:
- false
- HTML Attribute:
- open
-
instance.placement {Coral.Overlay.placement}
-
- Default Value:
- Coral.Overlay.placement.RIGHT
- HTML Attribute:
- placement
-
instance.returnFocus {Coral.mixin.overlay.returnFocus}
-
- Default Value:
- Coral.mixin.overlay.returnFocus.OFF
- HTML Attribute:
- returnfocus
-
instance.returnFocus {String}
-
- Inherited From:
Properties:
Name Type Value Description ON String on When the overlay is closed, the element that was focused before the it was shown will be focused again. OFF String off Nothing will be focused when the overlay is closed. -
instance.target {Coral.Overlay.target | HTMLElement | String}
-
- Inherited From:
- Default Value:
- null
- HTML Attribute:
- target
-
instance.trapFocus {Coral.mixin.overlay.trapFocus}
-
- Default Value:
- Coral.mixin.overlay.trapFocus.OFF
- HTML Attribute:
- trapfocus
-
instance.trapFocus {String}
-
- Inherited From:
Properties:
Name Type Value Description ON String on Focus is trapped such that the use cannot focus outside of the overlay. OFF String off The user can focus outside the overlay as normal. -
instance.variant {Coral.Tooltip.variant}
Reflected -
- Default Value:
- Coral.Tooltip.variant.INFO
- HTML Attribute:
- variant
-
instance.within {HTMLElement | String}
-
- Inherited From:
- Default Value:
- window
The point on the target we should anchor to when positioning.
The point on the overlay we should anchor from when positioning.
The collision handling strategy when positioning the overlay relative to a target.
The Tooltip content element.
The amount of time in miliseconds to wait before showing the tooltip when the target is interacted with.
Whether to focus the tooltip when opened or not. By default Tooltips do not require the focus to be changed,
but in case some content needs to be focused, setting focusOnShow="on" would handle this. It also accepts an
instance of HTMLElement or a selector like ':first-child' or 'button:last-of-type'. If the selector returns
multiple elements, it will focus the first element inside the overlay that matches the selector.
Whether to focus the overlay, when opened or not. By default the overlay itself will get the focus. It also
accepts an instance of HTMLElement or a selector like ':first-child' or 'button:last-of-type'. If the selector
returns multiple elements, it will focus the first element inside the overlay that matches the selector.
Whether this component is hidden or not.
Whether the tooltip should show itself when the target is interacted with.
The distance the overlay should be from its target.
Whether this overlay is open or not.
The placement of the overlay. This property sets Coral.Tooltip#alignMy and
Coral.Tooltip#alignAt.
Whether to return focus to the previously focused element when closed.
Return focus options.
The element the overlay should position relative to. It accepts values from Coral.Overlay.target, as
well as a DOM element or a CSS selector. If a CSS selector is provided, the first matching element will be used.
If a target is not specified, the overlay will not respect Coral.Overlay#alignMy,
Coral.Overlay#alignAt, or Coral.Overlay#collision.
Whether to trap tabs and keep them within the overlay.
Focus trap options.
The variant of tooltip.
The bounding element for the overlay. The overlay will be sized and positioned such that it is contained within
this element. It accepts both a DOM Element or a CSS selector. If a CSS selector is provided, the first matching
element will be used.
Methods
-
instance.get
-
- Parameters:
-
Name Type Description property String The name of the property to fetch the value of. - Returns:
-
Property value. {*}
- Inherited From:
-
instance.hide
-
- Returns:
-
this, chainable {Coral.Component}
- Inherited From:
-
instance.hide
-
- Returns:
-
this, chainable {Coral.Component}
-
instance.off
-
- Parameters:
-
Name Type Optional Description eventName String No
The event name to stop listening for. selector String Yes
The selector that was used for event delegation. func function No
The function that was passed to on()
.useCapture Boolean Yes
Only remove listeners with useCapture
set to the value passed in. - Returns:
-
this, chainable. {Coral.Component}
- Inherited From:
-
instance.on
-
- Parameters:
-
Name Type Optional Default Description eventName String No
The event name to listen for. selector String Yes
The selector to use for event delegation. func function No
The function that will be called when the event is triggered. useCapture Boolean Yes
Whether or not to listen during the capturing or bubbling phase. - Returns:
-
this, chainable. {Coral.Component}
- Inherited From:
-
instance.remove
-
- Inherited From:
-
instance.reposition
-
- Inherited From:
-
instance.returnFocusTo
-
- Parameters:
-
Name Type Description element HTMLElement The element to return focus to. This must be a DOM element, not a jQuery object or selector. - Returns:
-
this, chainable {Coral.Component}
-
instance.set
-
- Parameters:
-
Name Type Description property String The name of the property to set. value * The value to set the property to. silent Boolean If true, events should not be triggered as a result of this set. - Returns:
-
this, chainable. {Coral.Component}
- Inherited From:
-
instance.show
-
- Returns:
-
this, chainable {Coral.Component}
- Inherited From:
-
instance.show
-
- Returns:
-
this, chainable {Coral.Component}
-
instance.trigger
-
- Parameters:
-
Name Type Optional Default Description eventName String No
The event name to trigger. props Object Yes
Additional properties to make available to handlers as event.detail
.bubbles Boolean Yes
Set to false
to prevent the event from bubbling.cancelable Boolean Yes
Set to false
to prevent the event from being cancelable. - Returns:
-
CustomEvent object {CustomEvent}
- Inherited From:
Get the value of a property.
Hide this component.
Close the overlay.
Remove an event listener.
Add an event listener.
Non-destructively remove this element. It can be re-added by simply appending it to the document again.
It will be garbage collected if there are no more references to it.
Re-position the overlay if it's currently open.
Set the element that focus should be returned to when the overlay is hidden.
Set a single property.
Show this component.
Open the overlay and set the z-index accordingly.
Trigger an event.
Events
-
coral-overlay:beforeclose
-
- Callback Parameters:
-
Name Type Description event Object Event object.
Name Type Description event.preventDefault function Call to stop the overlay from closing.
-
coral-overlay:beforeopen
-
- Callback Parameters:
-
Name Type Description event Object Event object.
Name Type Description event.preventDefault function Call to stop the overlay from opening.
-
coral-overlay:close
-
- Callback Parameters:
-
Name Type Description event Object Event object.
-
coral-overlay:open
-
- Callback Parameters:
-
Name Type Description event Object Event object.
-
coral-component:attached
-
- Callback Parameters:
-
Name Type Description event Object Event object.
- Inherited From:
- Deprecated:
- since 1.14.0, use
MutationObserver
instead.
- since 1.14.0, use
-
coral-component:detached
-
- Callback Parameters:
-
Name Type Description event Object Event object.
- Inherited From:
- Deprecated:
- since 1.14.0, use
MutationObserver
instead.
- since 1.14.0, use
-
coral-component:ready
-
- Callback Parameters:
-
Name Type Description event Object Event object.
- Inherited From:
- Deprecated:
- since 1.9.0, use
Coral.commons.ready()
instead.
- since 1.9.0, use
Triggerred before the component is closed with
hide()
or instance.open = false
.
Triggerred before the component is opened with
show()
or instance.open = true
.
Triggerred after the component is closed with
hide()
or instance.open = false
Triggerred after the overlay is opened with
show()
or instance.open = true
Triggered when the component is attached to the DOM.
Triggered when the component is detached to the DOM.
Triggerred when the component has been upgraded and is ready for use.