# toggle-selection

> Toggle current selected content in browser

Latest version **2.1.0** (published 2026-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install toggle-selection
pnpm add toggle-selection
yarn add toggle-selection
bun add toggle-selection
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2026-04-25 |
| First published | 2015-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | sudodoki |
| Maintainers | sudodoki |
| Keywords | selection, toggle, browser, deselect |

## Links

- npm: https://www.npmjs.com/package/toggle-selection
- Repository: https://github.com/sudodoki/toggle-selection
- Homepage: https://github.com/sudodoki/toggle-selection#readme
- Issues: https://github.com/sudodoki/toggle-selection/issues
- npm.io page: https://npm.io/package/toggle-selection

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2026-04-25
- 2.0.0 — 2026-04-06
- 1.0.6 — 2017-07-24
- 1.0.5 — 2016-07-26
- 1.0.4 — 2015-10-10
- 1.0.3 — 2015-09-02
- 1.0.2 — 2015-09-02
- 1.0.1 — 2015-09-02
- 1.0.0 — 2015-09-02

## README

# Toggle Selection

Simple module exposing function that deselects current browser selection and returns function that restores selection.

```
var deselect = require('toggle-selection');
var reselect = deselect(); // remove all selection
// … 
// do something with current selection, text, etc;
// …
reselect(); // restore selection
```

All credits go to [@shvaikalesh](https://github.com/shvaikalesh).

# [Example](http://sudodoki.name/toggle-selection/example/)

![example recording](http://g.recordit.co/YPu6mHvcKe.gif)

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