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
{{ message }}
Repository navigation
Commit 78c94e3
Browse filesBrowse the repository at this point in the historyBrowse files
The same with less code is `<Popup trigger="click" mode="auto">`.
223
+
224
+
### Props
225
+
226
+
| Prop | Type | Meaning |
227
+
| --- | --- | --- |
228
+
|`open`|`boolean` (or signal) | Whether it is shown (default `true`); not used with `trigger`|
229
+
|`trigger`|`"hover" \| "click"`| Let the popup open and close itself (see below) |
230
+
|`openDelay`|`number`|`trigger="hover"`: ms on the anchor before it opens (default `500`) |
231
+
|`closeDelay`|`number`|`trigger="hover"`: ms after the pointer left before it closes (default `200`) |
232
+
|`mode`|`"hint" \| "auto" \| "manual"`| How it takes part in input (default `"hint"`, see below) |
233
+
|`onOpenChange`|`(open, reason) => void`|`"auto"`: the compositor asks it to close |
234
+
|`closeOnEscape`|`boolean`|`"auto"`: Escape closes it (default `true`) |
235
+
|`closeOnOutsidePress`|`boolean`|`"auto"`: a press outside it and its anchor closes it (default `true`) |
236
+
|`onInterestChange`|`(interested) => void`| The pointer entered / left the anchor or, unless `"hint"`, the popup |
237
+
|`onAnchorPress`|`() => void`| The anchor was pressed |
238
+
|`placement`|`"top" \| "bottom" \| "left" \| "right"`| The side of the anchor it goes to (default `"bottom"`) |
239
+
|`align`|`"start" \| "center" \| "end"`| Alignment along that side (default `"center"`) |
240
+
|`offset`|`number`| Distance from the anchor in logical pixels (default `0`) |
241
+
|`collision`|`"flip" \| "none"`|`"flip"` (default) moves it to the opposite side when that has more room on the output and slides it along the side to stay on the output |
242
+
|`layer`|`"top" \| "window"`|`"top"` (default): above every window. `"window"`: right above its own window, so windows stacked higher cover it |
243
+
|`style`|`SSDStyle`| Styling of the popup box itself |
244
+
245
+
### Modes
246
+
247
+
|`mode`| Pointer input | Closed by the compositor |
248
+
| --- | --- | --- |
249
+
|`"hint"` (default) | Falls through to whatever is below | Never |
250
+
|`"auto"`| Taken, also above other windows' clients | On a press outside, Escape, its window hidden, another `"auto"` popup opening |
251
+
|`"manual"`| Taken | Never |
252
+
253
+
The compositor never changes `open` itself: it calls `onOpenChange(false,
254
+
reason)` and your config decides. An `"auto"` popup without `onOpenChange` or
255
+
`trigger` gets no close requests (and leaves Escape to the window). `reason` is one of:
256
+
257
+
|`reason`| When |
258
+
| --- | --- |
259
+
|`"outside-press"`| A press outside the popup (and the popups nested in it) and outside its anchor |
260
+
|`"escape"`| Escape, for the most recently opened `"auto"` popup. While one is open, Escape does not reach the focused window; set `closeOnEscape={false}` to keep Escape for the window |
261
+
|`"anchor-gone"`| Its window was hidden (minimized, moved to another workspace) |
262
+
|`"other-popup"`| Another `"auto"` popup opened that is not nested in this one |
263
+
264
+
### Triggers
265
+
266
+
`trigger` keeps the open state for you, like `interestfor` / `popovertarget`
267
+
in browsers:
268
+
269
+
-`"hover"`: opens after the pointer rested `openDelay` ms on the anchor and
270
+
closes `closeDelay` ms after it left both the anchor and (unless `"hint"`) the
271
+
popup. Coming back within `closeDelay` keeps it open.
272
+
-`"click"`: each press of the anchor toggles it.
273
+
274
+
A `trigger` popup also closes on `onOpenChange` requests; your own
275
+
`onOpenChange` is still called. Set `trigger` once and do not switch it on and
276
+
off.
277
+
278
+
### Hover inside a popup
279
+
280
+
Outside popups, hover goes to the innermost node with `onHoverChange` only.
281
+
Inside an `"auto"` / `"manual"` popup it covers the whole ancestor chain, like
282
+
the DOM's `:hover`: the buttons in the popup, the popup, its anchor and the
283
+
anchor's ancestors all count as hovered. So `open={hover}` driven by the
284
+
anchor's `onHoverChange` keeps a menu open while the pointer is on it.
285
+
286
+
### How a popup differs from an ordinary child
287
+
288
+
-**Position**: it is sized by its content (its children are laid out as a
289
+
column) and takes no space in the parent's layout.
290
+
-**Not clipped**: the rounded corners of the window and `overflow: 'hidden'`
291
+
ancestors do not cut it.
292
+
-**Stacking**: drawn in its own pass, above every window (`layer="top"`) and
293
+
below layer-shell bars and overlays. A popup nested in a popup is drawn with
294
+
its outer popup.
295
+
-**Painting**: it is an ordinary decoration subtree: `style`, `boxShadow`,
296
+
[paint shaders](./paint.md), labels, images and signal-driven `opacity` all
297
+
work. A `<ShaderEffect/>` inside a popup draws its children but not its
298
+
effect.
299
+
-**Window animations**: while its window is drawn with an animated transform
300
+
(open / close, minimize, scaling), the popup is neither drawn nor hit.
301
+
Dragging a window moves its popups with it.
302
+
-`open` only toggles visibility: a closed popup keeps its layout, so opening it
0 commit comments