Coder Social home page Coder Social logo

range-num's Introduction

RangeNum

A vanilla web component that combines an <input type="range"> and an <input type="number"> and keeps their values/attributes in sync.

Installation

npm install @potch/range-num

Usage

// 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");
<!-- in your markup -->
<label>score <range-num min="0" max="10" value="5" /></label>
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 <input> elements are visible to DOM methods like document.querySelectorAll('input')

Configuration

The following attributes will be propagated from the <range-num> to its inputs:

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

Demo

npm run demo

range-num's People

Contributors

potch avatar

Stargazers

Chris Burnell avatar  avatar AliG avatar Paul Robert Lloyd avatar Jason Garber avatar Jason Weathered avatar Naiyer Asif avatar Lene Saile avatar Nirawit Jittipairoj avatar nicolas avatar Andrew Chou avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.