Skip to content
This repository was archived by the owner on Jun 14, 2020. It is now read-only.
Craig Michael Thompson edited this page Jan 4, 2014 · 9 revisions

Tips Add speech bubble tips to qTip2

The speech bubble tips plugin allows you to add nifty callout pointers to your tooltips. A wide range of options are available to style the tips, including height and width, colour and orientation/position on the tooltip. They even adjust with your tooltip when viewport adjustment is enabled!

Elements

When the tip plugin is in use on a tooltip, a new element becomes available within the API elements object, which references the newly created tip:

$('.selector').qtip({
	content: {
		text: 'Tips plugin element'
	},
	events: {
		render: function(event, api) {
			// Grab the tip element
			var elem = api.elements.tip;
		}
	}
})

Styling

Styling the tip's background and border colours is done via CSS, not the options below. These are detected from the styles set on the qtip-tip element listed above. If no valid style can be found for the background or border colour properties, qTip will look for styles on specific elements, depending on what it's looking for:

border-color

  • qtip-tip element
  • qtip-titlebar element - If present and tip overlaps
  • qtip-content element

background-color

  • qtip-tip element
  • qtip-titlebar element - If present and tip overlaps
  • qtip-content element
  • qtip element

If no valid style can be found on any of these elements, the initially detected style of the qtip-tip element will be used. A notable exception to the inheritance is the border property, which can be used to override the detected CSS border-width.


#000000 = Invalid style!

Since, by default, most browsers default to using pure black (rgb(0,0,0), #000 etc.) as the default colour, if qTip2 detects this it will look elsewhere for the styles as listed above. If you need to use pure black, the best work around is to use something very close to it visually, such as rgb(0,0,1) or #000001.


style.tip.corner

Values

true, "Corner", false (Default: true)

Overview

Defines where in relation to the tooltip the speech bubble tip is applied. Check-out the positioning docs for a full set of corner strings.

Examples

Let's create a regular qTip with a tip whose corner is inherited from the position.my option:

$('.selector').qtip({
	content: {
		text: 'I have a nice little callout pointer... nifty huh?'
	},
	style: {
		tip: {
			corner: true
		}
	}
});

We can also manually specify a different corner like so (if viewport adjustment is enabled, the tip position will not be adjusted):

$('.selector').qtip({
	content: {
		text: 'I have a nice little callout pointer... nifty huh?'
	},
	style: {
		tip: {
			corner: 'left center'
		}
	}
});

See also

Notes

  • When set to true, the tip position will be inherited from the position.my property and adjusted automatically if viewport adjustment is enabled.
  • The positioning values of 'center' and 'center center' are not valid positioning values in this plugin.

style.tip.mimic

Values

"Corner", false (Default: false)

Overview

Used in conjunction with style.tip.corner, this option overrides what corner type is rendered. Specifying a corner string here will cause the tip to render as this corner type, regardless of its position in relation to the tooltip.

You can also specify a single corner property e.g. "left" or "center", which will cause the tip to inherit its other properties from the corner string. This is primarily useful when using mimic with the position.viewport functionality.

Examples

Let's create a qTip with a similar tip style to ClueTip, whose tip arrow is equilateral and placed toward the top of the tooltip.

$('.selector').qtip({
	content: {
		text: 'I look very similar to a ClueTip tooltip in terms of my callout pointer.'
	},
	style: {
		tip: {
			corner: 'right top',
			mimic: 'right center'
		}
	}
});

As mentioned above, we can also use mimic with a single value too, to make for example the tip mimic 'center' and comply with viewport adjustment changes:

$('.selector').qtip({
	content: {
		text: 'My tip will mimic the center style regardless of position or viewport adjustment!'
	},
	position: {
		viewport: $(window) // Adjust position to keep within the window
	},
	style: {
		tip: {
			corner: 'right top',
			mimic: 'center' // Single 'center' value here
		}
	}
});

See also

Notes

  • This option overrides the presentation of the tip only. It does not effect the tips position!

style.tip.border

Values

true, Integer (Default: true)

Overview

This option determines the width of the border that surrounds the tip element, much like the CSS border-width property of regular elements. If a boolean true is passed, the border width will be detected automatically based on the border-width of the side the tip falls on. See the styling section for more information on this.

Examples

Let's create a qTip with a style to Google Maps tooltips, whose arrow blends with the border of the tooltip:

$('.selector').qtip({
	content: {
		text: 'I look very similar to a Google Maps tooltip!'
	},
	style: {
		classes: 'qtip-light',
		tip: {
			corner: 'bottom center',
			mimic: 'bottom left',
			border: 1,
			width: 88,
			height: 66
		}
	}
});

Notes

  • Unlike qTip1 the tip border follows the normal CSS property and applies the border outside the element, not inside.
  • See the styling section for more information on border-width detection

style.tip.width

Values

Integer (Default: 6)

Overview

Determines the width of the rendered tip in pixels, in relation to the side of the tooltip it lies upon i.e. when the tip position is on the left or right, this quantity actually refers to the tips height in visual terms, and vice versa.

Examples

Let's make a tooltip with an elongated tip width

$('.selector').qtip({
	content: {
		text: 'My callout pointer looks a bit wackier than usual'
	},
	style: {
		tip: {
			corner: true,
			width: 24
		}
	}
});

See also

Notes


style.tip.height

Values

Integer (Default: 6)

Overview

Determines the height of the rendered tip in pixels, in relation to the side of the tooltip it lies upon i.e. when the tip position is on the left or right, this quantity actually refers to the tips width in visual terms, and vice versa.

Examples

Let's make a tooltip with an elongated tip height

$('.selector').qtip({
	content: {
		text: 'My callout pointer looks a bit wackier than usual'
	},
	style: {
		tip: {
			corner: true,
			height: 24
		}
	}
});

See also

Notes


style.tip.offset

Values

Integer (Default: 0)

Overview

Determines the offset of the tip in relation to its current corner position.

Examples

Say your tooltip is positioned at the bottom left of your target, but you want the tip shifted slightly to left instead of flush with the side of the tooltip:

$('.selector').qtip({
	content: {
		text: 'My callout pointer looks a bit wackier than usual'
	},
	style: {
		tip: {
			corner: true,
			offset: 5 // Give it 5px offset from the side of the tooltip
		}
	}
});

See also

Notes

  • This value is relative i.e. depending on which corner the tooltip is set it will behave differently.
  • If your value is too large positioning problems can occur. Don't exceed a value equal to the height/width of the tooltip if possible.
  • Negative values will only be applied to 'center' positioned tooltips e.g. top center, left center.
Clone this wiki locally