Overlay
Anchored popup built on the browser Popover API, positioned with floating-ui.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Open state, kept in sync with the native popover (setting it shows or hides the popover). |
placement | Placement | bottom-start | Preferred placement (floating-ui names). The one in use is reflected as `current-placement`. |
disabled-cross-axis | boolean | false | Do not flip across the cross axis when there is no room (only along the main axis). |
fit-anchor | boolean | false | Make the overlay exactly as wide as the anchor. |
free-width | boolean | false | By default the overlay is at least as wide as its anchor; set this to size it by its content only. |
anchor | string | HTMLElement | undefined | undefined | Anchor element, or (attribute) the id of the anchor. Falls back to the element whose `popovertarget` is this overlay's id. |
Events
| Name | Type | Description |
|---|---|---|
toggle | ToggleEvent | Native popover toggle: `newState` is `open` or `closed`. |
beforetoggle | ToggleEvent | Native, cancelable, fired before the state changes. |
CSS custom properties
Grouped by the element and state they target. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-overlay--offset-y | pixel | 8px | Distance between the anchor and the overlay along the main axis. |
--c2-overlay--offset-x | pixel | 0px | Shift along the cross axis (towards the end for `*-start`, the start for `*-end`). |
--c2-overlay--viewport-padding | pixel | 8px | Minimum gap kept between the overlay and the viewport edges. |
--c2-overlay--transition-duration | time | 150ms | Open/close fade and scale; `0ms` disables it. |
--c2-overlay__backdrop--background | color | transparent | The `::backdrop` behind the popover. |