You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/website/src/routes/docs/headless/popover/index.mdx
+156-5Lines changed: 156 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -201,18 +201,21 @@ We can add a manual popover by adding the `popover="manual"` prop, or `manual` s
201
201
202
202
We can also enable programmatic behavior with popovers. Qwik UI provides several functions you can use to control this behavior.
203
203
204
-
<AnatomyTable
204
+
<APITable
205
205
propDescriptors={[
206
206
{
207
207
name: 'showPopover()',
208
+
type: 'QRL',
208
209
description: 'Opens the popover.',
209
210
},
210
211
{
211
212
name: 'hidePopover()',
213
+
type: 'QRL',
212
214
description: 'Closes the popover.',
213
215
},
214
216
{
215
217
name: 'togglePopover()',
218
+
type: 'QRL',
216
219
description: 'Toggles the popover between the open and closed state.',
217
220
},
218
221
]}
@@ -344,6 +347,7 @@ To do that, we can add the `listbox` class to the popover component.
344
347
If you need to override any of the listbox properties, use the following CSS variables:
345
348
346
349
<AnatomyTable
350
+
firstColumnLabel="Property"
347
351
propDescriptors={[
348
352
{
349
353
name: 'margin',
@@ -401,11 +405,11 @@ Here's the CSS imported from the example:
401
405
}
402
406
}
403
407
404
-
.animate-in {
408
+
.popover-showing {
405
409
animation: fadeIn both500msease;
406
410
}
407
411
408
-
.animate-out {
412
+
.popover-closing {
409
413
animation: fadeOut both500msease;
410
414
}
411
415
```
@@ -414,7 +418,7 @@ Here's the CSS imported from the example:
414
418
415
419
### Transition declarations
416
420
417
-
Transitions use the same classes for entry and exit animations. Those being `.popover-showing` and `.popover-closing`. They are explained move in the section above.
421
+
Transitions use the same classes for entry and exit animations. Those being `.popover-showing` and `.popover-closing`. They are explained more in the `Caveats` section.
418
422
419
423
> The [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) is another native solution that aims to solve animating between states. Support is currently in around **~70%** of browsers.
420
424
@@ -430,7 +434,22 @@ To read more about the popover API you can check it out on:
430
434
431
435
## Backdrops
432
436
433
-
<Showcasename="backdrop" />
437
+
Supported browsers provide a `::backdrop` pseudo element. For those looking to add a backdrop, the modal component might be a better option, as it provides more browser support for backdrops.
438
+
439
+
A backdrop across all browsers in the popover is possible too, but it requires a bit of extra work on the consumer side.
440
+
441
+
```tsx
442
+
/* I style this as if it is the backdrop */
443
+
<Popoverid="my-backdrop">
444
+
<divclass="wrap">
445
+
<divclass="content">
446
+
<Slot />
447
+
</div>
448
+
</div>
449
+
</Popover>
450
+
```
451
+
452
+
That said, if browser support is not a priority, feel free to use the native `::backdrop`. They are still supported in every major browser.
434
453
435
454
## Additional Examples
436
455
@@ -445,3 +464,135 @@ Automatically places the listbox based on available space. **You must set flip t
445
464
placement but with different strategies. Using both can result in a continuous reset
446
465
loop as they try to override each other's work.
447
466
</Note>
467
+
468
+
### Popover
469
+
470
+
<APITable
471
+
propDescriptors={[
472
+
{
473
+
name: 'id',
474
+
type: 'string',
475
+
description: `Popover's id. Should match the popover target.`,
476
+
},
477
+
{
478
+
name: 'popover',
479
+
type: 'union',
480
+
description:
481
+
'Defines the popover behavior, can be auto or manual. Default is auto.',
482
+
},
483
+
{
484
+
name: 'manual',
485
+
type: 'boolean',
486
+
description:
487
+
'A manual popover needs to be manually hidden, such as toggling the button or programmatically.',
488
+
},
489
+
{
490
+
name: 'floating',
491
+
type: 'boolean',
492
+
description: 'Enables extra JavaScript behavior for floating elements.',
493
+
},
494
+
{
495
+
name: 'anchorRef',
496
+
type: 'Signal',
497
+
description: 'Signal reference that can be passed for floating behavior.',
498
+
},
499
+
{
500
+
name: 'flip',
501
+
type: 'boolean',
502
+
description:
503
+
'Flips the placement of the popover when it starts to collide with the boundaries.',
504
+
},
505
+
{
506
+
name: 'gutter',
507
+
type: 'number',
508
+
description: 'The space between the floating element and the anchored element.',
509
+
},
510
+
{
511
+
name: 'placement',
512
+
type: 'union',
513
+
info: ` | 'top'
514
+
| 'top-start'
515
+
| 'top-end'
516
+
| 'right'
517
+
| 'right-start'
518
+
| 'right-end'
519
+
| 'bottom'
520
+
| 'bottom-start'
521
+
| 'bottom-end'
522
+
| 'left'
523
+
| 'left-start'
524
+
| 'left-end';`,
525
+
description:
526
+
'Flips the placement of the popover when it starts to collide with the boundaries.',
527
+
},
528
+
{
529
+
name: 'autoPlacement',
530
+
type: 'boolean',
531
+
description: 'Automatically places the listbox based on available space.',
532
+
},
533
+
{
534
+
name: '[popover]',
535
+
type: 'selector',
536
+
description: 'Selects the popover on all browsers.',
537
+
},
538
+
{
539
+
name: ':popover-open',
540
+
type: 'selector',
541
+
description: 'Native supported pseudo element when the popover is open.',
542
+
},
543
+
{
544
+
name: '.popover-open',
545
+
type: 'class',
546
+
description: 'Polyfill class added to style unsupported browsers.',
547
+
},
548
+
{
549
+
name: '.popover-showing',
550
+
type: 'class',
551
+
description: 'Class to animate entry behavior.',
552
+
},
553
+
{
554
+
name: '.popover-closing',
555
+
type: 'class',
556
+
description: 'Class to animate close behavior.',
557
+
},
558
+
{
559
+
name: 'listbox',
560
+
type: 'class',
561
+
description: 'Class to add to the popover component for listbox behavior.',
562
+
},
563
+
]}
564
+
/>
565
+
566
+
### Popover Trigger
567
+
568
+
<APITable
569
+
propDescriptors={[
570
+
{
571
+
name: 'popovertarget',
572
+
type: 'union',
573
+
description: 'Accepts a string that matches the id of the popover.',
574
+
},
575
+
]}
576
+
/>
577
+
578
+
### usePopover hook
579
+
580
+
<APITable
581
+
propDescriptors={[
582
+
{
583
+
name: 'showPopover()',
584
+
type: 'QRL',
585
+
description: 'Opens the popover.',
586
+
},
587
+
{
588
+
name: 'hidePopover()',
589
+
type: 'QRL',
590
+
description: 'Closes the popover.',
591
+
},
592
+
{
593
+
name: 'togglePopover()',
594
+
type: 'QRL',
595
+
description: 'Toggles the popover between the open and closed state.',
0 commit comments