x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<div class="tw:p-6 tw:max-w-7xl tw:mx-auto tw:space-y-8"> <!-- Header / Introduction --> <div class="tw-callout"> <p class="tw:mb-1 tw:text-sm tw:font-mono"> <strong>TOOLTIP:</strong> Informational overlay that appears on hover or keyboard focus<br> <strong>PLACEMENTS:</strong> Top | Bottom | Left | Right<br> <strong>ALIGNMENTS:</strong> Start | Center | End<br> <strong>SIZES:</strong> Small | Default | Large </p> <p class="tw:mb-0 tw:text-sm"> Use tooltips to provide brief, supplementary descriptions for UI elements. They appear on hover and keyboard focus, and auto-reposition when near viewport edges. Requires Stimulus controller. </p> </div> <!-- Section 1: Default Usage --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Default Usage</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Default:</strong> Tooltip appears above the element, centred. Add <code>data-controller="tooltip"</code> and <code>data-tooltip-content-value</code> to any element. </p> </div> <div class="tw:flex tw:flex-wrap tw:gap-4"> <button class="tw-btn tw-btn-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Save your changes"> Save </button> <button class="tw-btn tw-btn-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Discard and go back"> Cancel </button> <button class="tw-btn tw-btn-danger" type="button" data-controller="tooltip" data-tooltip-content-value="Permanently remove this item"> Delete </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button class="tw-btn tw-btn-primary" data-controller="tooltip" data-tooltip-content-value="Save your changes">Save</button></code> </div> </div> <!-- Section 2: All Placements --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Placements</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Placements:</strong> Control where the tooltip appears relative to its trigger using <code>data-tooltip-placement-value</code>. Options: <code>top</code> (default), <code>bottom</code>, <code>left</code>, <code>right</code>. </p> </div> <div class="tw:flex tw:flex-wrap tw:items-center tw:justify-center tw:gap-6 tw:py-8"> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Tooltip on top" data-tooltip-placement-value="top"> Top </button> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Tooltip on bottom" data-tooltip-placement-value="bottom"> Bottom </button> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Tooltip on left" data-tooltip-placement-value="left"> Left </button> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Tooltip on right" data-tooltip-placement-value="right"> Right </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button data-controller="tooltip" data-tooltip-content-value="..." data-tooltip-placement-value="bottom">...</button></code> </div> </div> <!-- Section 3: Alignment Variants --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Alignment</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Alignment:</strong> Fine-tune positioning along the cross axis using <code>data-tooltip-align-value</code>. Options: <code>start</code>, <code>center</code> (default), <code>end</code>. Works with all placements. </p> </div> <!-- Top alignments --> <h3 class="tw-h5 tw:mb-3">Top placement</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:mb-6"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to start" data-tooltip-placement-value="top" data-tooltip-align-value="start"> Top Start </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to center" data-tooltip-placement-value="top" data-tooltip-align-value="center"> Top Center </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to end" data-tooltip-placement-value="top" data-tooltip-align-value="end"> Top End </button> </div> <!-- Bottom alignments --> <h3 class="tw-h5 tw:mb-3">Bottom placement</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:mb-6"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to start" data-tooltip-placement-value="bottom" data-tooltip-align-value="start"> Bottom Start </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to center" data-tooltip-placement-value="bottom" data-tooltip-align-value="center"> Bottom Center </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to end" data-tooltip-placement-value="bottom" data-tooltip-align-value="end"> Bottom End </button> </div> <!-- Left alignments --> <h3 class="tw-h5 tw:mb-3">Left placement</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:mb-6"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to start" data-tooltip-placement-value="left" data-tooltip-align-value="start"> Left Start </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to center" data-tooltip-placement-value="left" data-tooltip-align-value="center"> Left Center </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to end" data-tooltip-placement-value="left" data-tooltip-align-value="end"> Left End </button> </div> <!-- Right alignments --> <h3 class="tw-h5 tw:mb-3">Right placement</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:mb-6"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to start" data-tooltip-placement-value="right" data-tooltip-align-value="start"> Right Start </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to center" data-tooltip-placement-value="right" data-tooltip-align-value="center"> Right Center </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to end" data-tooltip-placement-value="right" data-tooltip-align-value="end"> Right End </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button data-controller="tooltip" data-tooltip-content-value="..." data-tooltip-placement-value="right" data-tooltip-align-value="start">...</button></code> </div> </div> <!-- Section 4: Size Variants --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Size Variants</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Sizes:</strong> Use <code>data-tooltip-size-value</code> to control tooltip size. Options: <code>sm</code> (compact), default, <code>lg</code> (prominent). </p> </div> <div class="tw:flex tw:flex-wrap tw:items-center tw:gap-6 tw:py-4"> <button class="tw-btn tw-btn-outline-primary tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="Small tooltip" data-tooltip-size-value="sm"> Small </button> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Default tooltip"> Default </button> <button class="tw-btn tw-btn-outline-primary tw-btn-lg" type="button" data-controller="tooltip" data-tooltip-content-value="Large tooltip with more emphasis" data-tooltip-size-value="lg"> Large </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button data-controller="tooltip" data-tooltip-content-value="..." data-tooltip-size-value="sm">...</button></code> </div> </div> <!-- Section 5: Auto-Repositioning --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Auto-Repositioning</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Auto-flip:</strong> When a tooltip would overflow the viewport, it automatically flips to the opposite side. Try hovering the buttons near the edges of the preview area. The tooltip also nudges along the cross axis to stay within bounds. </p> </div> <div class="tw:flex tw:justify-between tw:py-4"> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="This tooltip may flip if near the left edge" data-tooltip-placement-value="left"> Left Edge </button> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="This tooltip stays centred" data-tooltip-placement-value="top"> Centre </button> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="This tooltip may flip if near the right edge" data-tooltip-placement-value="right"> Right Edge </button> </div> <div class="tw:flex tw:justify-between tw:py-4"> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="Top tooltip near the top of the page may flip to bottom" data-tooltip-placement-value="top"> Top Edge </button> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="Bottom tooltip near the bottom may flip to top" data-tooltip-placement-value="bottom"> Bottom Edge </button> </div> </div> <!-- Section 6: Keyboard Accessibility --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Keyboard Accessibility</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Keyboard:</strong> Tooltips appear on keyboard focus (<code>focusin</code>) and dismiss on blur (<code>focusout</code>) or <code>Escape</code> key. Tab through the elements below to see tooltips triggered by keyboard focus. </p> </div> <div class="tw:flex tw:flex-wrap tw:items-end tw:gap-4 tw:py-4"> <div> <label class="tw-form-label" for="tooltip-input">Username</label> <input type="text" id="tooltip-input" class="tw-form-control" placeholder="Enter username" data-controller="tooltip" data-tooltip-content-value="Your unique account identifier" data-tooltip-placement-value="top"> </div> <a href="#" class="tw-btn tw-btn-outline-primary" data-controller="tooltip" data-tooltip-content-value="Opens the help centre in a new tab" data-tooltip-placement-value="top"> Help </a> <button class="tw-btn tw-btn-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Submit the form" data-tooltip-placement-value="top"> Submit </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><input class="tw-form-control" data-controller="tooltip" data-tooltip-content-value="..."></code> </div> </div> <!-- Section 7: Long Content --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Long Content</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Wrapping:</strong> Tooltips have a max width of 320px (<code>max-w-xs</code>) and wrap text automatically. Keep tooltip text concise, but longer descriptions are supported. </p> </div> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:py-4"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="This is a longer tooltip that demonstrates how text wraps within the maximum width constraint. Useful for providing more detailed context about an action."> Long tooltip </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Short"> Short tooltip </button> </div> </div> <!-- Section 8: Real-World Examples --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Real-World Examples</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Practical uses:</strong> Icon-only buttons that need a text label, truncated content that needs the full version, and form fields with supplementary guidance. </p> </div> <div class="tw:flex tw:flex-wrap tw:items-center tw:gap-4 tw:py-4"> <!-- Icon-only button with tooltip --> <button class="tw-btn tw-btn-icon tw-btn-outline-secondary" type="button" aria-label="Settings" data-controller="tooltip" data-tooltip-content-value="Settings" data-tooltip-placement-value="bottom"> <i class="fa-solid fa-gear"></i> </button> <!-- Icon-only button with tooltip --> <button class="tw-btn tw-btn-icon tw-btn-outline-secondary" type="button" aria-label="Download report" data-controller="tooltip" data-tooltip-content-value="Download report" data-tooltip-placement-value="bottom"> <i class="fa-solid fa-download"></i> </button> <!-- Icon-only button with tooltip --> <button class="tw-btn tw-btn-icon tw-btn-outline-danger" type="button" aria-label="Delete item" data-controller="tooltip" data-tooltip-content-value="Delete item" data-tooltip-placement-value="bottom"> <i class="fa-solid fa-trash"></i> </button> </div> <!-- Truncated text example --> <h3 class="tw-h5 tw:mb-3 tw:mt-6">Truncated text with full content in tooltip</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:py-4"> <span class="tw-badge tw-badge-secondary-subtle tw-text-truncate" data-controller="tooltip" data-tooltip-content-value="Application for Year 7 Entry — September 2026 Intake" data-tooltip-placement-value="top"> Application for Year 7 Entry — September 2026 Intake </span> </div> <!-- Form helper tooltip --> <h3 class="tw-h5 tw:mb-3 tw:mt-6">Form field with tooltip helper</h3> <div class="tw:py-4"> <div class="tw:flex tw:items-center tw:gap-1 tw:mb-1"> <label class="tw-form-label tw:mb-0" for="tooltip-email">Email address</label> <span class="tw:text-neutral-400 tw:cursor-help" data-controller="tooltip" data-tooltip-content-value="We'll only use this to send application updates" data-tooltip-placement-value="right" data-tooltip-size-value="sm"> <i class="fa-regular fa-circle-question"></i> </span> </div> <input type="email" id="tooltip-email" class="tw-form-control" placeholder="name@school.edu"> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button class="tw-btn tw-btn-icon" aria-label="Settings" data-controller="tooltip" data-tooltip-content-value="Settings">...</button></code> </div> </div></div>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
<div class="tw:p-6 tw:max-w-7xl tw:mx-auto tw:space-y-8"> <!-- Header / Introduction --> <div class="tw-callout"> <p class="tw:mb-1 tw:text-sm tw:font-mono"> <strong>TOOLTIP:</strong> Informational overlay that appears on hover or keyboard focus<br> <strong>PLACEMENTS:</strong> Top | Bottom | Left | Right<br> <strong>ALIGNMENTS:</strong> Start | Center | End<br> <strong>SIZES:</strong> Small | Default | Large </p> <p class="tw:mb-0 tw:text-sm"> Use tooltips to provide brief, supplementary descriptions for UI elements. They appear on hover and keyboard focus, and auto-reposition when near viewport edges. Requires Stimulus controller. </p> </div> <!-- Section 1: Default Usage --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Default Usage</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Default:</strong> Tooltip appears above the element, centred. Add <code>data-controller="tooltip"</code> and <code>data-tooltip-content-value</code> to any element. </p> </div> <div class="tw:flex tw:flex-wrap tw:gap-4"> <button class="tw-btn tw-btn-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Save your changes"> Save </button> <button class="tw-btn tw-btn-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Discard and go back"> Cancel </button> <button class="tw-btn tw-btn-danger" type="button" data-controller="tooltip" data-tooltip-content-value="Permanently remove this item"> Delete </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button class="tw-btn tw-btn-primary" data-controller="tooltip" data-tooltip-content-value="Save your changes">Save</button></code> </div> </div> <!-- Section 2: All Placements --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Placements</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Placements:</strong> Control where the tooltip appears relative to its trigger using <code>data-tooltip-placement-value</code>. Options: <code>top</code> (default), <code>bottom</code>, <code>left</code>, <code>right</code>. </p> </div> <div class="tw:flex tw:flex-wrap tw:items-center tw:justify-center tw:gap-6 tw:py-8"> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Tooltip on top" data-tooltip-placement-value="top"> Top </button> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Tooltip on bottom" data-tooltip-placement-value="bottom"> Bottom </button> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Tooltip on left" data-tooltip-placement-value="left"> Left </button> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Tooltip on right" data-tooltip-placement-value="right"> Right </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button data-controller="tooltip" data-tooltip-content-value="..." data-tooltip-placement-value="bottom">...</button></code> </div> </div> <!-- Section 3: Alignment Variants --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Alignment</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Alignment:</strong> Fine-tune positioning along the cross axis using <code>data-tooltip-align-value</code>. Options: <code>start</code>, <code>center</code> (default), <code>end</code>. Works with all placements. </p> </div> <!-- Top alignments --> <h3 class="tw-h5 tw:mb-3">Top placement</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:mb-6"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to start" data-tooltip-placement-value="top" data-tooltip-align-value="start"> Top Start </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to center" data-tooltip-placement-value="top" data-tooltip-align-value="center"> Top Center </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to end" data-tooltip-placement-value="top" data-tooltip-align-value="end"> Top End </button> </div> <!-- Bottom alignments --> <h3 class="tw-h5 tw:mb-3">Bottom placement</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:mb-6"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to start" data-tooltip-placement-value="bottom" data-tooltip-align-value="start"> Bottom Start </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to center" data-tooltip-placement-value="bottom" data-tooltip-align-value="center"> Bottom Center </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to end" data-tooltip-placement-value="bottom" data-tooltip-align-value="end"> Bottom End </button> </div> <!-- Left alignments --> <h3 class="tw-h5 tw:mb-3">Left placement</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:mb-6"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to start" data-tooltip-placement-value="left" data-tooltip-align-value="start"> Left Start </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to center" data-tooltip-placement-value="left" data-tooltip-align-value="center"> Left Center </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to end" data-tooltip-placement-value="left" data-tooltip-align-value="end"> Left End </button> </div> <!-- Right alignments --> <h3 class="tw-h5 tw:mb-3">Right placement</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:mb-6"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to start" data-tooltip-placement-value="right" data-tooltip-align-value="start"> Right Start </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to center" data-tooltip-placement-value="right" data-tooltip-align-value="center"> Right Center </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Aligned to end" data-tooltip-placement-value="right" data-tooltip-align-value="end"> Right End </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button data-controller="tooltip" data-tooltip-content-value="..." data-tooltip-placement-value="right" data-tooltip-align-value="start">...</button></code> </div> </div> <!-- Section 4: Size Variants --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Size Variants</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Sizes:</strong> Use <code>data-tooltip-size-value</code> to control tooltip size. Options: <code>sm</code> (compact), default, <code>lg</code> (prominent). </p> </div> <div class="tw:flex tw:flex-wrap tw:items-center tw:gap-6 tw:py-4"> <button class="tw-btn tw-btn-outline-primary tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="Small tooltip" data-tooltip-size-value="sm"> Small </button> <button class="tw-btn tw-btn-outline-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Default tooltip"> Default </button> <button class="tw-btn tw-btn-outline-primary tw-btn-lg" type="button" data-controller="tooltip" data-tooltip-content-value="Large tooltip with more emphasis" data-tooltip-size-value="lg"> Large </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button data-controller="tooltip" data-tooltip-content-value="..." data-tooltip-size-value="sm">...</button></code> </div> </div> <!-- Section 5: Auto-Repositioning --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Auto-Repositioning</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Auto-flip:</strong> When a tooltip would overflow the viewport, it automatically flips to the opposite side. Try hovering the buttons near the edges of the preview area. The tooltip also nudges along the cross axis to stay within bounds. </p> </div> <div class="tw:flex tw:justify-between tw:py-4"> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="This tooltip may flip if near the left edge" data-tooltip-placement-value="left"> Left Edge </button> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="This tooltip stays centred" data-tooltip-placement-value="top"> Centre </button> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="This tooltip may flip if near the right edge" data-tooltip-placement-value="right"> Right Edge </button> </div> <div class="tw:flex tw:justify-between tw:py-4"> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="Top tooltip near the top of the page may flip to bottom" data-tooltip-placement-value="top"> Top Edge </button> <button class="tw-btn tw-btn-outline-info tw-btn-sm" type="button" data-controller="tooltip" data-tooltip-content-value="Bottom tooltip near the bottom may flip to top" data-tooltip-placement-value="bottom"> Bottom Edge </button> </div> </div> <!-- Section 6: Keyboard Accessibility --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Keyboard Accessibility</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Keyboard:</strong> Tooltips appear on keyboard focus (<code>focusin</code>) and dismiss on blur (<code>focusout</code>) or <code>Escape</code> key. Tab through the elements below to see tooltips triggered by keyboard focus. </p> </div> <div class="tw:flex tw:flex-wrap tw:items-end tw:gap-4 tw:py-4"> <div> <label class="tw-form-label" for="tooltip-input">Username</label> <input type="text" id="tooltip-input" class="tw-form-control" placeholder="Enter username" data-controller="tooltip" data-tooltip-content-value="Your unique account identifier" data-tooltip-placement-value="top"> </div> <a href="#" class="tw-btn tw-btn-outline-primary" data-controller="tooltip" data-tooltip-content-value="Opens the help centre in a new tab" data-tooltip-placement-value="top"> Help </a> <button class="tw-btn tw-btn-primary" type="button" data-controller="tooltip" data-tooltip-content-value="Submit the form" data-tooltip-placement-value="top"> Submit </button> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><input class="tw-form-control" data-controller="tooltip" data-tooltip-content-value="..."></code> </div> </div> <!-- Section 7: Long Content --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Long Content</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Wrapping:</strong> Tooltips have a max width of 320px (<code>max-w-xs</code>) and wrap text automatically. Keep tooltip text concise, but longer descriptions are supported. </p> </div> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:py-4"> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="This is a longer tooltip that demonstrates how text wraps within the maximum width constraint. Useful for providing more detailed context about an action."> Long tooltip </button> <button class="tw-btn tw-btn-outline-secondary" type="button" data-controller="tooltip" data-tooltip-content-value="Short"> Short tooltip </button> </div> </div> <!-- Section 8: Real-World Examples --> <div class="tw:border-t tw:pt-6"> <h2 class="tw-h4 tw:mb-4">Real-World Examples</h2> <div class="tw-callout tw:mb-4"> <p class="tw:mb-0 tw:text-sm"> <strong>Practical uses:</strong> Icon-only buttons that need a text label, truncated content that needs the full version, and form fields with supplementary guidance. </p> </div> <div class="tw:flex tw:flex-wrap tw:items-center tw:gap-4 tw:py-4"> <!-- Icon-only button with tooltip --> <button class="tw-btn tw-btn-icon tw-btn-outline-secondary" type="button" aria-label="Settings" data-controller="tooltip" data-tooltip-content-value="Settings" data-tooltip-placement-value="bottom"> <i class="fa-solid fa-gear"></i> </button> <!-- Icon-only button with tooltip --> <button class="tw-btn tw-btn-icon tw-btn-outline-secondary" type="button" aria-label="Download report" data-controller="tooltip" data-tooltip-content-value="Download report" data-tooltip-placement-value="bottom"> <i class="fa-solid fa-download"></i> </button> <!-- Icon-only button with tooltip --> <button class="tw-btn tw-btn-icon tw-btn-outline-danger" type="button" aria-label="Delete item" data-controller="tooltip" data-tooltip-content-value="Delete item" data-tooltip-placement-value="bottom"> <i class="fa-solid fa-trash"></i> </button> </div> <!-- Truncated text example --> <h3 class="tw-h5 tw:mb-3 tw:mt-6">Truncated text with full content in tooltip</h3> <div class="tw:flex tw:flex-wrap tw:gap-4 tw:py-4"> <span class="tw-badge tw-badge-secondary-subtle tw-text-truncate" data-controller="tooltip" data-tooltip-content-value="Application for Year 7 Entry — September 2026 Intake" data-tooltip-placement-value="top"> Application for Year 7 Entry — September 2026 Intake </span> </div> <!-- Form helper tooltip --> <h3 class="tw-h5 tw:mb-3 tw:mt-6">Form field with tooltip helper</h3> <div class="tw:py-4"> <div class="tw:flex tw:items-center tw:gap-1 tw:mb-1"> <label class="tw-form-label tw:mb-0" for="tooltip-email">Email address</label> <span class="tw:text-neutral-400 tw:cursor-help" data-controller="tooltip" data-tooltip-content-value="We'll only use this to send application updates" data-tooltip-placement-value="right" data-tooltip-size-value="sm"> <i class="fa-regular fa-circle-question"></i> </span> </div> <input type="email" id="tooltip-email" class="tw-form-control" placeholder="name@school.edu"> </div> <div class="tw:mt-4 tw:text-sm tw:text-gray-600"> <code><button class="tw-btn tw-btn-icon" aria-label="Settings" data-controller="tooltip" data-tooltip-content-value="Settings">...</button></code> </div> </div></div>No notes provided.
No params configured.