Flyout
Unstyled anchored popup with light dismiss; its anchor toggles it.
Anchored, unstyled popup (a native portal): `Popover` without the card. Pressing the anchor toggles it; while open that press is the light-dismiss press outside the flyout, which native swallows, so it closes it instead of reopening it (no timing involved). Escape on the anchor closes it too.
Import
import { Flyout } from "@tarve/core";Usage
import { Button, Column, Flyout, Pressable, Text, theme } from "@tarve/core";
let open = true;
const actions = ["Rename", "Duplicate", "Delete"];
// Pressing the anchor again closes it: that press is the light-dismiss press outside the flyout.
<Flyout
id="actions"
open={open}
placement="bottom-end"
anchor={<Button variant="outline">Actions</Button>}
onOpenChange={(next) => {
open = next;
}}
>
<Column
style={{ minWidth: 160, padding: 4, radius: 8, background: theme.colors.card, borderWidth: 1, borderColor: theme.colors.border }}
>
{actions.map((action) => (
<Pressable
key={action}
onClick={() => (open = false)}
style={{ padding: { left: 8, right: 8, top: 6, bottom: 6 }, radius: 6, hover: { background: theme.colors.muted } }}
>
<Text>{action}</Text>
</Pressable>
))}
</Column>
</Flyout>Props
| Prop | Type | Default |
|---|---|---|
anchor required What the flyout hangs from. Buttons and Pressables keep their node; other content is wrapped in a Pressable. | Child | — |
id required | string | — |
open required | boolean | — |
anchorStyle | Style | — |
contentStyle Style of the content box; the flyout draws no surface of its own. | Style | — |
disabled | boolean | false |
label Accessible name of a wrapped anchor; defaults to its text. | string | — |
lightDismiss A press outside the flyout closes it without reaching what is under it. Default `true`. | boolean | true |
offset Distance from the anchor in px. Default 6. | number | 6 |
onOpenChange | (open: boolean) => void | — |
placement Default `"bottom-start"`; flips back into the window when it would leave it. | FlyoutPlacement | "bottom-start" |
Common props
Shared by every component. See descriptions →
childrenclassclassNamehighlightkeymotionFromonHighlightonPasteonPointerLeaveonPointerMoveonSizeonTransitionEndrovingGroupstyleTypes
type FlyoutPlacement = PopupSide | `${PopupSide}-start` | `${PopupSide}-end`;