# 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.

- Category: [Overlays](https://tarve.dev/docs.md#overlays)
- Import: `import { Flyout } from "@tarve/core";`
- Props type: `FlyoutProps`
- Source: [packages/core/src/flyout.ts:47](https://github.com/omarcosr/tarve/blob/main/packages/core/src/flyout.ts#L47)

## Usage

```tsx title="Flyout.tsx"
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 | Description |
| --- | --- | --- | --- |
| `anchor` (required) | `Child` | — | What the flyout hangs from. Buttons and Pressables keep their node; other content is wrapped in a Pressable. |
| `id` (required) | `string` | — |  |
| `open` (required) | `boolean` | — |  |
| `anchorStyle` | `Style` | — |  |
| `contentStyle` | `Style` | — | Style of the content box; the flyout draws no surface of its own. |
| `disabled` | `boolean` | `false` |  |
| `label` | `string` | — | Accessible name of a wrapped anchor; defaults to its text. |
| `lightDismiss` | `boolean` | `true` | A press outside the flyout closes it without reaching what is under it. Default `true`. |
| `offset` | `number` | `6` | Distance from the anchor in px. Default 6. |
| `onOpenChange` | `(open: boolean) => void` | — |  |
| `placement` | `FlyoutPlacement` | `"bottom-start"` | Default `"bottom-start"`; flips back into the window when it would leave it. |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="FlyoutPlacement"
type FlyoutPlacement = PopupSide | `${PopupSide}-start` | `${PopupSide}-end`;
```

Previous: [Popover](https://tarve.dev/docs/components/Popover.md) · Next: [Tooltip](https://tarve.dev/docs/components/Tooltip.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Flyout · Index for agents: https://tarve.dev/llms.txt
