# Tooltips, Popovers and Dropdowns

Content anchored to an element. Exact props: `widgets-get-component-props`.

---

## DTooltip

A short, non-critical hint about an element. `Component` is the element the tooltip is attached to (required); the children are the tooltip content:

```tsx
<DTooltip
  Component={<DButtonIcon icon="Info" variant="link" aria-label={t('fees.info')} />}
  withFocus
>
  {t('fees.tooltip')}
</DTooltip>
```

Use a focusable trigger (`DButtonIcon`, not a bare `DIcon`) and `withFocus`, so keyboard users can open the tooltip too: by default it opens only on hover.

| Prop | Use |
|------|-----|
| `Component` | Required. The trigger |
| `placement` | `top` (default), `right`, `bottom`, `left`, and their `-start`/`-end` variants |
| `withHover` (default on), `withFocus`, `withClick` | What opens it |
| `open` | The initial open state |
| `size`, `offSet`, `padding` | Presentation |

A tooltip holds a hint, not information the user needs to complete a task.

## DPopover

Richer content (text, a list, actions) anchored to a trigger. It is controlled: `open` is required, `setOpen` updates it, and `renderComponent(open)` renders the trigger:

```tsx
const [open, setOpen] = useState(false);

<DPopover
  open={open}
  setOpen={setOpen}
  renderComponent={() => (
    <DButton text={t('account.more')} variant="outline" onClick={() => setOpen(!open)} />
  )}
>
  <AccountDetails />
</DPopover>
```

## DDropdown

A menu of actions. Each action has a required `label`, and optionally `onClick` or `href`, `icon`, `color`, `disabled`; `isDivider` renders a separator:

```tsx
<DDropdown
  actions={[
    { label: t('common.edit'), icon: 'Pencil', onClick: onEdit },
    { label: t('common.download'), icon: 'Download', onClick: onDownload },
    { label: '', isDivider: true },
    { label: t('common.delete'), icon: 'Trash2', color: 'danger', onClick: onDelete },
  ]}
/>
```

| Prop | Use |
|------|-----|
| `actions` | Required. The menu items |
| `dropdownToggle` | A render function `({ open, toggle }) => …` for a custom trigger |
| `placement` | `auto` (default), `down`, `up`, `start`, `end` |
| `alignment` | `start` (default), `end`, `center` |
| `asPortal` | Renders the menu in a portal |

---

## Common mistakes

| Wrong | Right |
|-------|-------|
| `<DTooltip theme="dark">` | `DTooltip` has no `theme` |
| A tooltip that holds required information | Show it in the content, or use `DPopover` |
| A divider action without `label` | `label` is required: `{ label: '', isDivider: true }` |
| `DDropdown` to pick a value | `DInputSelect` or `DSelect` (`modyo://docs/widgets/components-selects`) |
