# makeup-expander

> Creates the basic interactivity for an element that expands and collapses another element.

Latest version **0.13.0** (published 2026-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install makeup-expander
pnpm add makeup-expander
yarn add makeup-expander
bun add makeup-expander
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.13.0 |
| Published | 2026-03-31 |
| First published | 2017-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 31.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 47 |
| Author | Ian McBurnie |
| Maintainers | dylanpiercey, sendlo, ianmcburnie, agliga, saiponnada, artblue, lulavalva |
| Keywords | makeup, ebay, accessibility, a11y |

## Links

- npm: https://www.npmjs.com/package/makeup-expander
- Repository: https://github.com/makeup/makeup-js.git#master
- Homepage: https://github.com/makeup/makeup-js/tree/master#readme
- Issues: https://github.com/makeup/makeup-js/issues
- npm.io page: https://npm.io/package/makeup-expander

## Dependencies (3)

- [makeup-next-id](https://npm.io/package/makeup-next-id.md) ^0.6.0
- [makeup-focusables](https://npm.io/package/makeup-focusables.md) ^0.5.0
- [makeup-exit-emitter](https://npm.io/package/makeup-exit-emitter.md) ^0.6.0

## Recent versions

- 0.13.0 (latest) — 2026-03-31
- 0.7.0-0 (beta) — 2019-03-14
- 0.12.0 — 2026-02-07
- 0.11.10 — 2026-01-14
- 0.11.9 — 2025-08-19
- 0.11.8 — 2025-08-13
- 0.11.7 — 2025-04-22
- 0.11.6 — 2025-04-04
- 0.11.5 — 2025-01-29
- 0.11.4 — 2024-12-20
- 0.11.3 — 2024-10-24
- 0.11.2 — 2024-09-03
- 0.11.1 — 2024-08-27
- 0.11.0 — 2024-06-23
- 0.10.2 — 2024-06-17
- … 29 more at https://npm.io/package/makeup-expander/versions

## README

# makeup-expander

Creates the basic interactivity for an element that expands and collapses another element.

## Experimental

This module is still in an experimental state, until it reaches v1 you must consider all minor releases as breaking changes.

## Example 1: Uses aria-expanded

In the first example, our expanded content is adjacent to the host element.

```html
<div class="expander">
  <button class="expander__host">Click for Popover</button>
  <div class="expander__content">
    <p>Any kind of HTML control can go inside...</p>
    <p>A link: <a id="foo" href="http://www.ebay.com">www.ebay.com</a></p>
    <p>A button: <button>Click Me</button></p>
    <p>An input: <input type="text" aria-label="Dummy textbox" /></p>
    <p>A checkbox: <input type="checkbox" aria-label="Dummy checkbox" /></p>
  </div>
</div>
```

```js
import Expander from "makeup-expander";

// get an element reference
const widgetEl = document.querySelector(".expander");

// options
const options = {
  expandOnClick: true,
};

// get widget instance
const widget = new Expander(widgetEl, options);
```

Clicking the button will now toggle its expanded state (setting aria-expanded on the element, by default). CSS can be used to display the content accordingly, for example:

```css
.expander__content {
  display: none;
}

.expander__host[aria-expanded="true"] ~ .expander__content {
  display: block;
}
```

## Example 2: Uses a class

In this second example, we use a class. This can be useful when our expanded content is not adjacent to the host element or when aria-expanded is not required.

```html
<div class="expander">
  <span>
    <input class="expander__host" type="text" />
  </span>
  <div class="expander__content">
    <p>Any kind of HTML control can go inside...</p>
    <p>A link: <a id="foo" href="http://www.ebay.com">www.ebay.com</a></p>
    <p>A button: <button>Click Me</button></p>
    <p>An input: <input type="text" aria-label="Dummy textbox" /></p>
    <p>A checkbox: <input type="checkbox" aria-label="Dummy checkbox" /></p>
  </div>
</div>
```

A CSS classname is required as our styling hook. This can be passed in via the options.

```js
// options
const options = {
  expandedClass: "expander--expanded",
  expandOnFocus: true,
};
```

Setting focus on the host adds the chosen class to the root. CSS can be used to display the content accordingly, for example:

```css
.expander--expanded .expander__content {
  display: block;
}
```

## Params

- `el`: the root widget el
- `options.alwaysDoFocusManagement`: whether `focusManagement` option (see below) should apply for mouse click
- `options.ariaControls`: specify whether `aria-controls` relationship should be created between host and overlay (default: true)
- `options.autoCollapse`: applies a collapse behavior (`collapseOnClick`, `collapseOnFocusOut`, `collapseOnMouseOut`) based on expand behaviour (default: false)
- `options.collapseOnClickOut`: whether the content should collapse when clicking outside of content (default: false)
- `options.collapseOnFocusOut`: whether the content should collapse when focus leaves the content (default: false)
- `options.collapseOnMouseOut`: whether the content should collapse when mouse leaves the content (default: false)
- `options.collapseOnHostReFocus`: whether the content should collapse when focus moves back to the host from content (default: false). This cannot be set to true when expandOnFocus is true
- `options.contentSelector`: the query selector for the expandee element in relation to the widget (default: '.expander\_\_content')
- `options.expandOnClick`: whether the host should be click activated (default: false)
- `options.expandOnFocus`: whether the host should be focus activated (default: false)
- `options.expandOnHover`: whether the host should be hover activated (default: false)
- `options.focusManagement`: where keyboard focus should go (null, 'content', 'focusable', 'interactive', or ID reference) when expanded via `ENTER` or `SPACEBAR` (default: null)
- `options.hostSelector`: the query selector for the host element in relation to the widget (default: '.expander\_\_host')
- `options.expandedClass`: the class which will be used on the root element to signify expanded state.
- `options.useAriaExpanded`: set to false for tooltips (default: true)

## Properties

Set the following properties to true or false to enable or disable the behaviour.

- `collapseOnClickOut`
- `collapseOnFocusOut`
- `collapseOnMouseOut`
- `expanded`
- `expandOnClick`
- `expandOnFocus`
- `expandOnHover`

## Events

- `expander-collapse`
- `expander-expand`

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