- Welcome
- Getting started
- Latest updates
- Foundations
-
Components
- Accordion
- Alert
- Alignment
- Aria live
- Autosuggest
- Badge
- Banner alert
- Bar chart
- Blockquote
- Bottom navigation
- Bottom sheet
- Breadcrumb
- Breakpoint
- Button
- Calendar
- Card
- Card List
- Card button
- Carousel
- Checkbox
- Chip
- Chip group
- Code
- Content cards
- Data Table
- Datepicker
- Description list
- Dialog
- Divider
- Drawer
- Field Set
- Flare
- Flat list
- Flight leg
- Floating action button
- Floating notification
- Form label
- Form validation
- Graphic promotion
- Horizontal navigation
- Icon
- Image
- Infinite scroll
- Link
- List
- Map
- Mobile scroll container
- Modal
- Navigation bar
- Nudger
- Overlay
- Page indicator
- Pagination
- Panel
- Phone input
- Picker
- Popover
- Price
- Progress bar
- Radio button
- Rating
- Scrollable calendar
- Section header
- Section list
- Select
- Skeleton
- Skip link
- Slider
- Snackbar
- Snippet
- Spinner
- Split input
- Star rating
- Switch
- Table
- Text
- Text input
- Theming
- Ticket
- Toast
- Tooltip
- Touchable native feedback
- Touchable overlay
- Content
- Accessibility
Tooltip
Tooltips appear on hover of a particular element and are used to provide additional context/information to the user. They are generally text only and are triggered on pointer-based interfaces.
Default
Dark appearance
Tooltips can have a dark look too.
Alternative positioning
Tooltips can be positioned on any side.
Without padding
Tooltips are also available without padding, for displaying full-width content within them. In this example, the tooltip contains a full-width line.
bpk-component-tooltip
Backpack tooltip component.
Installation
Check the main Readme for a complete installation guide.
Usage
import { useRef } from 'react';
import BpkText from '@skyscanner/backpack-web/bpk-component-text';
import BpkTooltip from '@skyscanner/backpack-web/bpk-component-tooltip';
const App = () => (
const targetRef = useRef(null);
const target = (
<div ref={targetRef} className={'my-tooltip-target'}>
<BpkText textStyle="lg">LHR</BpkText>
</div>
);
<BpkTooltip
ariaLabel="London Heathrow"
id="my-tooltip"
target={target}
>
London Heathrow
</BpkTooltip>
);
Props
Property | PropType | Required | Default Value |
---|---|---|---|
ariaLabel | string | true | - |
id | string | true | - |
children | node | true | - |
target | node | true | - |
hideOnTouchDevices | bool | false | true |
placement | oneOf(['top', 'right', 'bottom', 'left']) | false | 'bottom' |
padded | bool | false | true |
portalStyle | object | false | null |
portalClassName | string | false | null |
popperModifiers | arrayOf(object) | false | null |
renderTarget | func | false | null |
type | oneOf(TOOLTIP_TYPES.light, TOOLTIP_TYPES.dark) | false | TOOLTIP_TYPES.light |
Prop Details
ariaLabel
Tooltips are invisible to assistive technologies such as screen readers. To improve accessibility, ariaLabel is required to describe the content of the tooltip to assistive technologies.
The label will be used on the target element, so any existing aria-label attached to target will be overridden.
popperModifiers
Please refer to the documentation for the underlying positioning library "Popper.js". You can achieve various behaviours such as allowing the tooltip to overflow the viewport etc.
target
target should be a DOM element with a ref attached to it.
Made with ❤️ by Skyscanner © 2023
© 2023 Skyscanner Backpack. Page last updated on Nov 2, 2022, 14:59