|
| 1 | +--- |
| 2 | +title: Qwik UI | Tooltip |
| 3 | +--- |
| 4 | + |
| 5 | +import { Tooltip } from '@qwik-ui/headless'; |
| 6 | +import { MainExample, Example1 } from './examples'; |
| 7 | +import { CodeExample } from '../../../../../components/code-example/code-example'; |
| 8 | +import { KeyboardInteractionTable } from '../../../../../components/keyboard-interaction-table/keyboard-interaction-table'; |
| 9 | +import { APITable } from '../../../../../components/api-table/api-table'; |
| 10 | + |
| 11 | +# Tooltip |
| 12 | + |
| 13 | +#### A popup that displays information realted to an element when the element receives keyboard focus or the mouse hovers over it. |
| 14 | + |
| 15 | +<MainExample> |
| 16 | + ```tsx |
| 17 | + <Tooltip |
| 18 | + content="I'm a tooltip!" |
| 19 | + class="bg-slate-200 dark:bg-gray-900 p-4 rounded-xl" |
| 20 | + > |
| 21 | + Hover over me! |
| 22 | + </Tooltip> |
| 23 | + ``` |
| 24 | +</MainExample> |
| 25 | + |
| 26 | +## Building blocks |
| 27 | + |
| 28 | + <CodeExample> |
| 29 | + ```tsx |
| 30 | + import { component$ } from '@builder.io/qwik'; |
| 31 | + import { Tooltip } from '@qwik-ui/headless'; |
| 32 | + |
| 33 | + export default component$(() => ( |
| 34 | + <Tooltip content='Tooltip content'> |
| 35 | + Trigger content |
| 36 | + </Tooltip> |
| 37 | + )); |
| 38 | + ``` |
| 39 | + |
| 40 | + </CodeExample> |
| 41 | + |
| 42 | +## Examples |
| 43 | + |
| 44 | +### EXAMPLE: Describing Unlabelled Icon Link |
| 45 | + |
| 46 | +<Example1> |
| 47 | + ```tsx |
| 48 | + <Tooltip |
| 49 | + content="Clicking this icon takes you to Qwik UI's GitHub repository!" |
| 50 | + class="bg-slate-200 dark:bg-gray-900 p-4 rounded-xl" |
| 51 | + > |
| 52 | + <a href="https://github.com/qwikifiers/qwik-ui" class="mx-auto"> |
| 53 | + <GitHubIcon /> |
| 54 | + </a> |
| 55 | + </Tooltip> |
| 56 | + ``` |
| 57 | +</Example1> |
| 58 | + |
| 59 | +## Accessibility |
| 60 | + |
| 61 | +### Keyboard interaction |
| 62 | + |
| 63 | +<KeyboardInteractionTable keyDescriptors={ |
| 64 | + [ |
| 65 | + { |
| 66 | + keyTitle: 'Esc', |
| 67 | + description: 'Dismisses the Tooltip when focused.', |
| 68 | + }, |
| 69 | + |
| 70 | +] |
| 71 | +}/> |
| 72 | + |
| 73 | +## API |
| 74 | + |
| 75 | +### AccordionItem |
| 76 | + |
| 77 | +<APITable |
| 78 | + propDescriptors={[ |
| 79 | + { |
| 80 | + name: 'class', |
| 81 | + type: 'string', |
| 82 | + description: 'CSS classes to apply to the Tooltip.', |
| 83 | + }, |
| 84 | + { |
| 85 | + name: 'content', |
| 86 | + type: 'string', |
| 87 | + description: 'The content displayed in the Tooltip.', |
| 88 | + }, |
| 89 | + { |
| 90 | + name: 'durationMs', |
| 91 | + type: 'nummber', |
| 92 | + description: |
| 93 | + 'Sets a delay duration in milliseconds before the Tooltip is displayed.', |
| 94 | + }, |
| 95 | + { |
| 96 | + name: 'inline', |
| 97 | + type: 'boolean', |
| 98 | + description: 'Determines if the Tooltip is rendered inline.', |
| 99 | + }, |
| 100 | + { |
| 101 | + name: 'position', |
| 102 | + type: '"bottom" | "bottom-end" | "bottom-start" | "left" | "left-end" | "left-start" | "right" | "right-end" | "right-start" | "top" | "top-end" | "top-start"', |
| 103 | + description: 'Determines the position the Tooltip is rendered.', |
| 104 | + }, |
| 105 | + ]} |
| 106 | +/> |
0 commit comments