@sliderjs/core
v0.0.2
Published
Headless slider library - framework-agnostic and TypeScript-friendly
Maintainers
Readme
@sliderjs/core
A headless slider library – pure logic without UI opinions. Framework-agnostic, fully typed with TypeScript, and designed for flexibility.
What is a Headless Slider?
A headless slider is a slider component that provides all the functionality and logic without prescribing any specific UI implementation. This means:
- No built-in styling – you control the appearance
- No DOM assumptions – works with any framework or vanilla JavaScript
- Framework adapters – official packages for React, Vue, and Angular
- Full control – build exactly what you need
- TypeScript support – full type safety out of the box
Installation
npm install @sliderjs/coreBasic Usage
JavaScript
const Slider = require('@sliderjs/core');
const slider = new Slider({
min: 0,
max: 100,
value: 50,
step: 1
});
slider.on('change', ({ value }) => {
console.log('Value changed to:', value);
});
slider.setValue(75);TypeScript
import Slider, { SliderOptions, ChangeEvent } from '@sliderjs/core';
const options: SliderOptions = {
min: 0,
max: 100,
value: 50,
step: 1
};
const slider = new Slider(options);
slider.on('change', (event: ChangeEvent) => {
console.log('Value changed to:', event.value);
});
slider.setValue(75);API
Constructor Options
min(number, default: 0) – minimum valuemax(number, default: 100) – maximum valuevalue(number) – initial valuestep(number, default: 1) – step incrementdisabled(boolean, default: false) – disabled state
Methods
setValue(value)– set the slider valuegetValue()– get the current valuegetConfig()– get slider configurationreset()– reset to minimum valueenable()– enable the sliderdisable()– disable the slideron(event, callback)– listen to eventsoff(event, callback)– remove event listeneremit(event, data)– emit custom events
Events
change– fired when value changes, includes{ value: number }
Framework Adapters
@sliderjs/react– React component@sliderjs/vue– Vue component@sliderjs/angular– Angular component
License
ISC
