# ember-basic-dropdown

> The basic dropdown that your ember app needs

Latest version **9.0.1** (published 2026-10-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-basic-dropdown
pnpm add ember-basic-dropdown
yarn add ember-basic-dropdown
bun add ember-basic-dropdown
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 9.0.1 |
| Published | 2026-10-12 |
| First published | 2015-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 243 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 159 |
| Author | Miguel Camba |
| Maintainers | cibernox, mkszepp |
| Keywords | ember, ember-addon, dropdown, ui |

## Links

- npm: https://www.npmjs.com/package/ember-basic-dropdown
- Repository: https://github.com/ember-power-addons/ember-basic-dropdown
- npm.io page: https://npm.io/package/ember-basic-dropdown

## Dependencies (6)

- [ember-modifier](https://npm.io/package/ember-modifier.md) ^4.3.0
- [ember-truth-helpers](https://npm.io/package/ember-truth-helpers.md) ^5.0.0
- [decorator-transforms](https://npm.io/package/decorator-transforms.md) ^2.4.0
- [ember-element-helper](https://npm.io/package/ember-element-helper.md) ^0.8.8
- [ember-style-modifier](https://npm.io/package/ember-style-modifier.md) ^4.6.0
- [@embroider/addon-shim](https://npm.io/package/@embroider/addon-shim.md) ^1.10.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 9.0.1 (latest) — 2026-10-12
- 9.0.0 — 2026-05-15
- 8.11.1 — 2026-05-08
- 8.11.0 — 2025-12-14
- 8.10.0 — 2025-12-13
- 8.9.0 — 2025-12-07
- 8.8.0 — 2025-10-12
- 8.7.0 — 2025-09-16
- 8.6.2 — 2025-06-04
- 8.6.1 — 2025-05-13
- 8.6.0 — 2025-02-22
- 8.5.0 — 2025-01-27
- 8.4.0 — 2024-11-12
- 8.3.0 — 2024-08-27
- 8.2.1 — 2024-08-22
- … 313 more at https://npm.io/package/ember-basic-dropdown/versions

## README

[![NPM](https://badge.fury.io/js/ember-basic-dropdown.svg)](https://www.npmjs.com/package/ember-basic-dropdown)
[![Ember Observer Score](https://emberobserver.com/badges/ember-basic-dropdown.svg)](https://emberobserver.com/addons/ember-basic-dropdown)
![Ember Version](https://img.shields.io/badge/ember-%3E%3D4.12-brightgreen?logo=emberdotjs&logoColor=white)
[![Discord](https://img.shields.io/badge/chat-discord-blue?style=flat&logo=discord)](https://discord.com/channels/480462759797063690/486202731766349824)
[![Build Status](https://github.com/ember-power-addons/ember-basic-dropdown/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/ember-power-addons/ember-basic-dropdown)

# ember-basic-dropdown

This is a very minimal dropdown. That means that it is agnostic about what it is going to contain.

It is intended to be a building block for more complex components but is perfectly usable.

### Features

- 🖊 **TypeScript support** – ships with type definitions for smooth TypeScript integration.
- ✨ **Glint support** – template type-checking out of the box for safer templates.
- 🚀 **FastBoot compatible** – works in server-rendered Ember apps.
- 🕶 **Shadow DOM support** – can be rendered inside shadow roots without breaking positioning or events.
- 🛠 **Addon v2 ready** – modern Ember Addon v2 format.
- 🎯 **Headless & lightweight** – provides dropdown logic and accessibility without forcing styles.
- 🔧 **Flexible API** – fully customizable trigger and content; you control the markup and styling.
- 🧩 **Composable** – integrates seamlessly with other Ember addons (e.g. [ember-power-select](https://www.ember-power-select.com)).
- ♿ **Accessible by default** – full keyboard navigation, ARIA attributes, and focus management built-in.
- 📱 **Responsive positioning** – automatic repositioning on scroll and viewport boundaries.

### Compatibility

- Embroider or ember-auto-import v2
- Ember.js v4.12 or above

### Installation

```
pnpm install ember-basic-dropdown
```

For more installation details see [documentation](https://ember-basic-dropdown.com/docs/installation)

### Usage

This component leverages contextual components for its API:

```glimmer-ts
import BasicDropdown from "ember-basic-dropdown/components/basic-dropdown";

<template>
  <BasicDropdown as |dd|>
    <dd.Trigger>Click me</dd.Trigger>
    <dd.Content>Content of the trigger</dd.Content>
  </BasicDropdown>
</template>
```

The yielded `dropdown` object is the public API of the component, and contains
properties and actions that you can use to control the component.

```js
{
  uniqueId: <string>,
  disabled: <boolean>,
  isOpen: <boolean>,
  actions: {
    open: <action>,
    close: <action>,
    toggle: <action>,
    reposition: <action>,
    registerTriggerElement: <action>,
    registerDropdownElement: <action>,
    getTriggerElement: <action>
  }
}
```

Check the full documentation with live examples in https://ember-basic-dropdown.com

### Features

#### Renders on the body or in place

By default this component will render the dropdown in the body using `#in-element` and absolutely
position it to place it in the proper coordinates.

You can opt out to this behavior by passing `renderInPlace=true`. That will add the dropdown just
below the trigger.

#### Close automatically when clicking outside the component

You don't need to care about adding or removing events, it does that for you.

You can make the dropdown content standout a little more by adding `overlay=true` to the content options, see example below. This will add a semi transparent overlay covering the whole screen. Also this will stop bubbling the click/touch event which closed the dropdown.

```glimmer-ts
import BasicDropdown from "ember-basic-dropdown/components/basic-dropdown";

<template>
  <BasicDropdown as |dd|>
    <dd.Trigger>Click me!</dd.Trigger>
    <dd.Content @overlay={{true}}>
      {{! here! }}
      content!
    </dd.Content>
  </BasicDropdown>
</template>
```

NOTE: If for some reason clicking outside a dropdown doesn't work, you might want to make sure the `<body>` spans the entire viewport. Adding a css rule like `body {min-height: 100vh;}` would do the trick. It ensures that wherever you click on the page, it will close the dropdown.

#### Close automatically when clicking inside the component

If you'd like the dropdown to close itself after a user clicks on it, you can use `dd.actions.close` from our public API.

```glimmer-ts
import BasicDropdown from 'ember-basic-dropdown/components/basic-dropdown';
import { on } from '@ember/modifier';

<template>
  <BasicDropdown as |dd|>
    <dd.Trigger>Click me!</dd.Trigger>
    <dd.Content>
      <div role="button" {{on "click" dd.actions.close}}>
        {{yield dd}}
      </div>
    </dd.Content>
  </BasicDropdown>
<template>
```

#### Keyboard and touchscreen support

The trigger of the component is focusable by default, and when focused can be triggered using `Enter` or `Space`.
It also listen to touch events so it works in mobile.

#### Easy to extend

The components provide hooks like `onFocus`, `onBlur`, `onKeydown`, `onMouseEnter` and more so
you can do pretty much anything you want.

#### Easy to animate.

You can animate it, in an out, with just CSS3 animations.
Check the example in the [Ember Power Select documentation](https://www.ember-power-select.com/cookbook/css-animations)

#### Intelligent and customizable positioning

This component is smart about where to position the dropdown. It will detect the best place to render
it based on the space around the trigger, and also will take care of reposition if if the screen is
resized, scrolled, the device changes it orientation or the content of the dropdown changes.

You can force the component to be fixed in one position by passing `verticalPosition = above | below` and/or `horizontalPosition = right | center | left`.

If even that doesn't match your preferences and you feel brave enough, you can roll your own positioning logic if you pass a `calculatePosition`
function. It's signature is:

```
calculatePosition(trigger, dropdown, { previousHorizontalPosition, horizontalPosition, previousVerticalPosition, verticalPosition, matchTriggerWidth })
```

The return value must be an object with this interface: `{ horizontalPosition, verticalPosition, style }` where
where `horizontalPosition` is a string (`"right" | "center" | "left"`), `verticalPosition` is also a string
(`"above" | "below"`) and `style` is an object with CSS properties, typically `top` and `left`/`right`.

#### Test helpers

It has a handy collection of test helpers to make interaction with the component seamless in your
test suite.

---
_Source: https://npm.io/package/ember-basic-dropdown · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
