An open API service indexing awesome lists of open source software.

https://github.com/potch/range-num

A simple web component that combines a range input and a number input
https://github.com/potch/range-num

Last synced: about 1 year ago
JSON representation

A simple web component that combines a range input and a number input

Awesome Lists containing this project

README

          

# RangeNum

A vanilla web component that combines an `` and an
`` and keeps their values/attributes in sync.

## Installation

`npm install @potch/range-num`

## Usage

```js
// provided as an ES Module
import RangeNum from "@potch/range-num";
RangeNum.register();

// If you'd like to use a different tag name
RangeNum.register("my-cool-range-num");
```

```html

score
```

```js
const el = document.querySelector("range-num");
el.rangeInput; // the inner input[type="range"]
el.numInput; // the inner input[type="number"]
```

RangeNum uses "light" Shadow Dom, meaning its internal `` elements are
visible to DOM methods like `document.querySelectorAll('input')`

## Configuration

The following attributes will be propagated from the `` to its
inputs:

- `disabled`
- `disabled` attribute can also be set to `"number"`, which will then only apply
to the underlying ``.
- `max`
- `min`
- `name`
- only propagated to the inner ``. This is done to ensure
only one input with that name appears in `FormData`.
- `readonly`
- applies only to the inner ``.
- `step`
- `value`
- latest `value` is synchronized to both inner inputs as well as the top-level
``

## Demo

`npm run demo`