Skip to content

Commit fc80f2b

Browse files
authored
Merge pull request #287 from shiroinegai/add-docs-tooltip
2 parents 52f6cc3 + e043762 commit fc80f2b

File tree

3 files changed

+148
-33
lines changed

3 files changed

+148
-33
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Slot, component$ } from '@builder.io/qwik';
2+
import { Tooltip } from '@qwik-ui/headless';
3+
import { GitHubIcon } from 'apps/website/src/components/icons/GitHubIcon';
4+
import { PreviewCodeExample } from 'apps/website/src/components/preview-code-example/preview-code-example';
5+
6+
export const MainExample = component$(() => {
7+
return (
8+
<PreviewCodeExample>
9+
<div q:slot="actualComponent">
10+
<Tooltip
11+
content="I'm a tooltip!"
12+
class="bg-slate-200 dark:bg-gray-900 p-4 rounded-xl"
13+
>
14+
Hover over me!
15+
</Tooltip>
16+
</div>
17+
<div q:slot="codeExample">
18+
<Slot />
19+
</div>
20+
</PreviewCodeExample>
21+
);
22+
});
23+
24+
export const Example1 = component$(() => {
25+
return (
26+
<PreviewCodeExample>
27+
<div q:slot="actualComponent">
28+
<Tooltip
29+
content="Clicking this icon takes you to Qwik UI's GitHub repository!"
30+
class="bg-slate-200 dark:bg-gray-900 p-4 rounded-xl"
31+
>
32+
<a href="https://github.com/qwikifiers/qwik-ui" class="mx-auto">
33+
<GitHubIcon />
34+
</a>
35+
</Tooltip>
36+
</div>
37+
<div q:slot="codeExample">
38+
<Slot />
39+
</div>
40+
</PreviewCodeExample>
41+
);
42+
});
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
/>

apps/website/src/routes/docs/headless/(components)/tooltip/index.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)