# Drop (`<z-drop>`)

> Floating panel positioned against a trigger with Floating UI — dropdowns, dropbars, and hover/click drops with delays and stretch sizing.

- **Kind:** hwc
- **Category:** overlays
- **Inherits:** `Hwc`, `Base`

## Attributes

| Attribute | Type | Default | From | Description |
| --- | --- | --- | --- | --- |
| `open` | `boolean` | `false` | — | Reflects the open state; setting it shows or hides the drop. |
| `dropdown` | `boolean` | `false` | — | Adds the `z-dropdown` class for dropdown styling. |
| `placement` | `Placement` | `'bottom-start'` | — | Floating UI placement: `top`/`right`/`bottom`/`left` with optional `-start`/`-end` (default `bottom-start`). |
| `mode` | `string` | `'click'` | — | Comma-separated activation modes: `click` (default) and/or `hover`. |
| `trigger` | `string` | `''` | — | Selector or id of the trigger element. Defaults to an element with `data-toggle`/`data-open` pointing at this drop, else the previous element sibling; `false` disables automatic binding. |
| `manual` | `boolean` | `false` | — | Disables automatic trigger binding; open/close only via attributes, methods, or `data-toggle`/`data-open`/`data-close`. |
| `delay-show` | `number` | `0` | — | Delay in milliseconds before showing on hover (default 0). |
| `delay-hide` | `number` | `150` | — | Delay in milliseconds before hiding when the pointer leaves (default 150), allowing travel into the drop. |
| `stretch` | `string` | `''` | — | Sizing against the trigger: empty/`trigger` sets the drop's min-width to the trigger width; `fill` stretches it to the available viewport width. Both cap max-height to the available space. |
| `offset` | `number \| undefined` | `undefined` | — | Distance in pixels from the trigger; defaults to the CSS enter-slide offset. |
| `inline` | `boolean` | `false` | — | Keeps the drop in its original DOM position instead of teleporting it to `document.body`. |
| `unmount` | `boolean` | `false` | — | Removes the rendered DOM after the close transition; the next show mounts it again. |
| `close-on-scroll` | `boolean` | `false` | — | Closes the drop when the page scrolls. |
| `no-esc-close` | `boolean` | `false` | — | Disables closing with the Esc key. |
| `no-bg-close` | `boolean` | `false` | — | Disables closing on outside clicks. |

### Inherited from `Hwc`

| Attribute | Type | Default | From | Description |
| --- | --- | --- | --- | --- |
| `i18n` | `string` | `''` | `Hwc` | Per-instance text overrides as `key: text` pairs, merged over the global `z-i18n` script and the built-in defaults. |
| `floating` | `string` | `''` | `Hwc` | Floating UI placement options (for example `offset` and `shiftPadding`) parsed as `key: value` pairs. |
| `force-prevent-rerender` | `boolean` | `false` | `Hwc` | Skips re-rendering after the first render; an existing `data-host-inner` child is adopted as the rendered DOM. |
| `template` | `string` | `''` | `Hwc` | Selector or id of an external element or `<template>` whose inner content is cloned in place of an inline `template[data-fn="template"]` child. |

### Inherited from `Base`

| Attribute | Type | Default | From | Description |
| --- | --- | --- | --- | --- |
| `cls` | `string` | `''` | `Base` | Adds classes to named parts as `key: classes` pairs; a plain string targets the default part. |
| `stl` | `string` | `''` | `Base` | Adds inline styles to named parts as `key: styles` pairs; a plain string targets the default part. |

## Styling Parts (`cls` / `stl`)

Default `cls` target: `drop`. Default `stl` target: `drop`.

| Key | Default class | cls | stl | Description |
| --- | --- | --- | --- | --- |
| `drop` | `z-drop` | ✓ | ✓ | The floating panel (default `z-drop`); the default `cls`/`stl` target. |

## CSS Variables

| Variable | Default | Scope | Affects | Description |
| --- | --- | --- | --- | --- |
| `--z-drop-enter-duration` | `120ms` | `z-drop > .z-drop` | `animation` | Duration of the enter animation. |
| `--z-drop-enter-timing` | `cubic-bezier(0.16, 1, 0.3, 1)` | `z-drop > .z-drop` | `animation` | Easing of the enter animation. |
| `--z-drop-icon-margin` | `0.5rem` | `.z-drop-parent-icon` | `margin-inline-start` | Inline-start margin of the parent chevron icon. |
| `--z-drop-icon-transition` | `0.3s transform` | `.z-drop-parent-icon` | `transition` | Transition of the parent chevron rotation. |
| `--z-drop-slide-x` | `0` | `z-drop > .z-drop` | — | Horizontal enter-slide offset for the current side. |
| `--z-drop-slide-y` | `-4px` | `z-drop > .z-drop` | — | Vertical enter-slide offset for the current side. |
| `--z-drop-width` | `18rem` | `.z-drop` | `width` | Default width of the drop panel. |
| `--z-drop-z-index` | `1020` | `.z-drop` | `z-index` | Stacking order of the drop panel. |
| `--z-dropbar-lg-padding` | `2.5rem 0` | `.z-dropbar-lg` | `padding` | Padding of the large dropbar variant. |
| `--z-dropdown-bg` | `var(--z-drop)` | `.z-dropdown` | `background-color` | Dropdown background base color, mixed with transparency using `--z-dropdown-bg-o`. |
| `--z-dropdown-bg-o` | `100%` | `.z-dropdown` | `background-color` | Dropdown background opacity percentage used in the mix. |
| `--z-dropdown-border-color` | `var(--z-border)` | `.z-dropdown` | `border-color` | Dropdown border base color, mixed with transparency using `--z-dropdown-border-color-o`. |
| `--z-dropdown-border-color-o` | `var(--z-border-o)` | `.z-dropdown` | `border-color` | Dropdown border opacity percentage used in the mix. |
| `--z-dropdown-border-width` | `1px` | `.z-dropdown` | `border-width` | Dropdown border width. |
| `--z-dropdown-color` | `var(--z-drop-f)` | `.z-dropdown` | `color` | Dropdown text base color, mixed with transparency using `--z-dropdown-color-o`. |
| `--z-dropdown-color-o` | `100%` | `.z-dropdown` | `color` | Dropdown text opacity percentage used in the mix. |
| `--z-dropdown-dropbar-bg` | `transparent` | `.z-dropdown-dropbar` | `background-color` | Dropbar-dropdown background base color, mixed with transparency using `--z-dropdown-dropbar-bg-o`. |
| `--z-dropdown-dropbar-bg-o` | `0%` | `.z-dropdown-dropbar` | `background-color` | Dropbar-dropdown background opacity percentage used in the mix. |
| `--z-dropdown-dropbar-shadow` | `none` | `.z-dropdown-dropbar` | `box-shadow` | Dropbar-dropdown box shadow. |
| `--z-dropdown-dropbar-width` | `auto` | `.z-dropdown-dropbar` | `width` | Dropbar-dropdown width. |
| `--z-dropdown-radius` | `var(--z-global-radius)` | `.z-dropdown` | `border-radius` | Dropdown corner radius. |
| `--z-dropdown-shadow` | `var(--z-global-shadow-small)` | `.z-dropdown` | `box-shadow` | Dropdown box shadow. |
| `--z-dropdown-width` | `auto` | `.z-dropdown` | `width` | Dropdown width. |
| `--z-dropnav-z` | `1020` | `.z-dropnav-dropbar` | `z-index` | Stacking order of the dropnav presentation. |

## Methods

| Method | Params | Returns | Description |
| --- | --- | --- | --- |
| `containsNode()` | `node: Node \| null` | `boolean` | Returns whether a node is inside the host or the floating panel (used for outside-click detection). |
| `destroy()` | `removeHost?: boolean = false` | `Promise<void>` | Closes and unmounts the drop DOM. |
| `getAnchorElement()` | — | `HTMLElement \| null` | Returns the element the drop is positioned against. |
| `hide()` | `restoreFocus?: boolean = false` | `Promise<void>` | Closes the drop. |
| `show()` | `trigger?: HTMLElement \| null` | `Promise<void>` | Opens the drop and positions it against the trigger. |
| `toggle()` | `trigger?: HTMLElement \| null` | `Promise<void>` | Opens the drop if closed, otherwise closes it. |

## Data Hooks

| Attribute | Values | Applies to | Role | Description |
| --- | --- | --- | --- | --- |
| `data-close` | — | `external-trigger` | `trigger` | Clicking the element closes the drop matched by the selector (usually `#id`). |
| `data-host-inner` | — | `descendant` | `config` | Marks the rendered inner wrapper so `force-prevent-rerender` can adopt server-rendered DOM without re-rendering. |
| `data-open` | — | `external-trigger` | `trigger` | Clicking the element opens the drop matched by the selector without toggling. |
| `data-part` | `drop` | `descendant` | `marker` | Marks the floating panel in adopted server-rendered DOM (`data-part="drop"`). |
| `data-reactive` | — | `descendant` | `config` | Opts the marked child (config script, data source, icons, or template) into live re-parsing when its DOM mutates. |
| `data-side` | — | `descendant` | `read-only` | Set by the component to the resolved placement side (`top`, `right`, `bottom`, `left`); selects the enter-animation direction. |
| `data-toggle` | — | `external-trigger` | `trigger` | Clicking the element toggles the drop matched by the selector (usually `#id`). |

## Child Content

- `<script data-fn="config">` — JSON configuration script parsed by the base class (i18n, cls, stl, floating).

  | Attribute | Required | Type | Description |
  | --- | --- | --- | --- |
  | `data-fn` | ✓ | `config` | Marks the script as configuration (value: `config`). |
  | `data-reactive` | — | `boolean` | Re-parses the configuration when the script mutates. |

- `<select data-fn="data-source">` — Hidden select parsed into grouped option data by the base class.

  | Attribute | Required | Type | Description |
  | --- | --- | --- | --- |
  | `data-fn` | ✓ | `data-source` | Marks the select as the data source (value: `data-source`). |
  | `data-reactive` | — | `boolean` | Re-parses the options when the select mutates. |

  - `<optgroup>` — Groups options under a label.

    | Attribute | Required | Type | Description |
    | --- | --- | --- | --- |
    | `label` | ✓ | `string` | Group header text; also the default group key. |
    | `disabled` | — | `boolean` | Disables every option in the group. |
    | `data-key` | — | `string` | Overrides the group key used in the parsed data. |
    | `data-keywords` | — | `comma-separated string` | Comma-separated keywords stored with the group's data. |

    - `<option>` — One option entry within the group.

      | Attribute | Required | Type | Description |
      | --- | --- | --- | --- |
      | `value` | — | `string` | Value carried by this option in the parsed data. |
      | `disabled` | — | `boolean` | Makes the option non-selectable. |
      | `selected` | — | `boolean` | Marks the option as initially selected. |
      | `data-keywords` | — | `comma-separated string` | Extra search terms, comma-separated; searched alongside the label and value. |

  - `<option>` — One ungrouped option entry.

    | Attribute | Required | Type | Description |
    | --- | --- | --- | --- |
    | `value` | — | `string` | Value carried by this option in the parsed data. |
    | `disabled` | — | `boolean` | Makes the option non-selectable. |
    | `selected` | — | `boolean` | Marks the option as initially selected. |
    | `data-keywords` | — | `comma-separated string` | Extra search terms, comma-separated. |

- `<template data-fn="icons">` — Instance-level icon repository.

  | Attribute | Required | Type | Description |
  | --- | --- | --- | --- |
  | `data-fn` | ✓ | `icons` | Marks the template as an icon source (value: `icons`). |
  | `data-reactive` | — | `boolean` | Re-parses the icons when the template mutates. |

  - `<*>` — One icon element.

    | Attribute | Required | Type | Description |
    | --- | --- | --- | --- |
    | `data-key` | ✓ | `string` | Icon key referenced by `$icons`. |

- `<template data-fn="template">` — Deferred content template mounted by the base class.

  | Attribute | Required | Type | Description |
  | --- | --- | --- | --- |
  | `data-fn` | ✓ | `template` | Marks the template for deferred mounting (value: `template`). |
  | `data-reactive` | — | `boolean` | Re-parses the template when it mutates. |

## CSS Classes

| Class | Role | Applies to | Description |
| --- | --- | --- | --- |
| `.z-drop` | `root` | `z-drop` | Root class of the floating panel. |
| `.z-drop-grid` | `element` | `.z-drop` | Grid layout for drop content columns. |
| `.z-drop-parent-icon` | `element` | `.z-drop` | Chevron icon on a parent trigger, rotated while its drop is open. |
| `.z-drop-stack` | `element` | `.z-drop` | Stacks grid columns vertically on small screens. |
| `.z-dropbar` | `element` | `.z-drop` | Full-width bar presentation anchored below the trigger. |
| `.z-dropbar-lg` | `element` | `.z-drop` | Large-padding variant of the dropbar. |
| `.z-dropdown` | `element` | `.z-drop` | Dropdown presentation: padded, bordered, rounded panel. |
| `.z-dropdown-dropbar` | `element` | `.z-drop` | Dropdown rendered as a full-width dropbar. |
| `.z-dropdown-nav` | `element` | `.z-drop` | Nav list inside a dropdown; marks the selected item. |
| `.z-dropnav-dropbar` | `element` | `.z-drop` | Dropnav rendered as a full-width dropbar. |

## Keyboard

| Keys | Action | When |
| --- | --- | --- |
| `Escape` | Closes the open drop (unless `no-esc-close`). | — |
| `ArrowDown` / `ArrowUp` / `Home` / `End` | Moves through `.z-dropdown-nav` links/buttons or `[role="menuitem"]` entries. | Focus is inside the drop. |

## Accessibility

| Part | Attributes | Description |
| --- | --- | --- |
| `drop` | — | Floating panel; no static ARIA attributes (the trigger carries the expanded state). |

> Register as an active drop so the shared toggle system can manage Esc/outside clicks and stacking above open modals.

> Give the trigger `aria-expanded`/`aria-controls` as appropriate; nav items in a dropdown receive `aria-selected` styling.

## Notes

- The panel teleports to `document.body` unless `inline` is set, and is kept positioned with Floating UI `autoUpdate`.
- Hover mode keeps the drop open while the pointer travels between trigger and panel; the follow-up click after a drag is suppressed.
- Drops stack above open modals by computing a z-index over `.z-modal.z-open`.

## Guides

- [Styling with cls and stl](https://next.0build.dev/docs/guides/styling.md)
- [Translating Components](https://next.0build.dev/docs/guides/i18n.md)
- [Icon Resolution](https://next.0build.dev/docs/guides/icons.md)
- [The data-source Convention](https://next.0build.dev/docs/guides/data-source.md)
- [Openers & Triggers](https://next.0build.dev/docs/guides/triggers.md)
- [Dialog Behavior](https://next.0build.dev/docs/guides/dialogs.md)
- [Utilities](https://next.0build.dev/docs/guides/utilities.md)
- [Runtime](https://next.0build.dev/docs/guides/runtime.md)

## Related

- [Dialog](https://next.0build.dev/docs/components/dialog.md)
- [Drawer](https://next.0build.dev/docs/components/drawer.md)
