### Install Svelte Range Slider Pips
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Installs the svelte-range-slider-pips package as a development dependency using either Yarn or npm. This is the initial step to include the slider component in your project.
```bash
yarn add svelte-range-slider-pips --dev # or
npm install svelte-range-slider-pips --save-dev # if you prefer npm
```
--------------------------------
### Installing Older Version of Svelte Range Slider Pips
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Provides instructions for installing version 2.3.1 of the Svelte Range Slider Pips component, which is compatible with Svelte 3. This is a fallback for projects unable to upgrade to Svelte 4/5. It includes commands for both Yarn and npm package managers.
```bash
yarn add svelte-range-slider-pips@2.3.1 --dev
# or
npm install svelte-range-slider-pips@2.3.1 --save-dev
```
--------------------------------
### Svelte Range Slider Keyboard Navigation Improvements
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
This example showcases the improved keyboard navigation in the Svelte Range Slider component, version 4. It illustrates how Ctrl/Cmd + Arrow keys move the slider by 1% of the total range, while Shift + Arrow or PageUp/PageDown keys move it by 10%. The example assumes a slider with min=0, max=100, and step=1, demonstrating the impact of these navigation changes on unit movement.
```svelte
```
--------------------------------
### Initialize Svelte Range Slider Pips with Event Listener (JavaScript)
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/tests/vanilla/esm.html
Initializes the Svelte Range Slider Pips component and sets up an event listener to capture changes. This script targets a specific HTML element for the slider and an output element for displaying values. It requires the 'svelte-range-slider-pips' module.
```javascript
import RangeSliderPips from './node_modules/svelte-range-slider-pips/dist/range-slider-pips.mjs';
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
// create and initialise the slider
const slider = document.querySelector('.my-slider');
const rangeSliderPips = new RangeSliderPips({
target: slider,
props: {
values: [-7, 7],
pips: true,
first: 'label',
last: 'label',
range: true,
min: -10,
max: 10
}
});
// listen for changes to the slider and update the output
const output = document.querySelector('#value-output');
rangeSliderPips.$on('change', function (e) {
output.innerHTML = e.detail.values;
});
}
};
```
--------------------------------
### CSS Example: State and Modifier Class Changes (v3 vs v4)
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Illustrates the difference in CSS selectors between v3 and v4 of the Svelte Range Slider Pips component. This shows the updated class names for targeting selected pips, highlighting a migration step.
```css
.rangeSlider .pip.selected {
background-color: blue;
}
/* After (v4): */
.rangeSlider .rsPip.rsSelected {
background-color: blue;
}
```
--------------------------------
### Configure Range Slider with Gap Controls
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Example of using new rangeGapMin and rangeGapMax properties to control the minimum and maximum distance between handles in a range slider. This functionality requires `range={true}` and can be combined with `pushy={true}`.
```svelte
```
--------------------------------
### Svelte Range Slider Pips Event Handling
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Demonstrates how to handle events dispatched by the Svelte Range Slider Pips component. Events include 'start', 'change', and 'stop', providing details about the slider's state at the time of the event. These events are crucial for reacting to user interactions. The `event.detail` object contains information like the active handle, values, and previous values.
```html
```
--------------------------------
### Svelte Range Slider: Event Handling for User Interactions
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Listens to 'start', 'change', and 'stop' events to track the user interaction lifecycle with the slider. These events provide details about the active handle, current value, and previous values.
```svelte
{#each eventLog as log}
{log}
{/each}
```
--------------------------------
### Install Svelte Range Slider Pips v4
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Update the svelte-range-slider-pips package to version 4 using npm, yarn, or pnpm.
```bash
npm install svelte-range-slider-pips@4
# or
yarn add svelte-range-slider-pips@4
# or
pnpm add svelte-range-slider-pips@4
```
--------------------------------
### Svelte Component: Applying Custom Theme Colors
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Demonstrates how to apply custom theme colors to the RangeSlider component in Svelte. It shows examples using the `style` prop for direct CSS declarations and the `class` prop for Tailwind CSS classes.
```svelte
```
--------------------------------
### Custom Range Value Formatting
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Example of using the `rangeFormatter` property to provide custom formatting for the range float display. This property accepts a function that receives the two range values and their percentages, allowing for complete control over the output, including HTML strings.
```svelte
`${v1} to ${v2}`}
/>
```
--------------------------------
### Svelte Range Slider Input Validation Example
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
This Svelte snippet demonstrates the enhanced input validation in version 4 of the Svelte Range Slider component. It shows how to set min, max, and precision properties, and includes ariaLabels for accessibility. The component automatically corrects invalid min/max values (e.g., min >= max) and ensures ariaLabels is an array, providing console feedback for developers.
```svelte
```
--------------------------------
### Enable Range Area Dragging in Svelte Range Slider
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
This snippet demonstrates how to enable dragging of the range area between handles in the Svelte Range Slider component. The 'draggy' property must be set to true, and the slider must be configured as a range slider (range={true}). Event handlers for 'start', 'change', and 'stop' are included to log the range values during interaction.
```svelte
console.log('Range drag started:', values)}
on:change={({ values }) => console.log('Range changed:', values)}
on:stop={({ values }) => console.log('Range drag ended:', values)}
/>
```
--------------------------------
### Vanilla JavaScript Instantiation
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Shows how to initialize the RangeSliderPips component in vanilla JavaScript by targeting a specific DOM element and passing configuration properties such as values, pips, min, max, and step.
```html
```
--------------------------------
### Multi-Thumb Configuration in Svelte
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Demonstrates creating a Svelte range slider with multiple handles using the 'values' array. Configurable with min, max, step, pips, 'all' label display, 'float' for floating labels, and 'hoverable' for interactive handles.
```svelte
Selected values: {values.join(', ')}
```
--------------------------------
### Usage as a Vanilla JS Component
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Shows how to use the RangeSlider component in a plain JavaScript environment by including the distributed script. It initializes the slider on a target div with specified properties upon DOMContentLoaded.
```html
```
--------------------------------
### Basic Svelte Integration
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Demonstrates how to import and use the RangeSlider component within a Svelte application, utilizing reactive data binding for the 'values' property and enabling pips.
```svelte
```
--------------------------------
### Svelte Range Slider Pips Configuration Options
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Defines the available configuration options for the Svelte Range Slider Pips component. These options control aspects like value formatting, animation physics, precision, and DOM element binding. Dependencies include the Svelte framework. Inputs are various data types (function, boolean, object, number, element), and outputs are the configured behavior of the slider.
```html
```
--------------------------------
### React Integration with Event Handling
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Illustrates integrating the Svelte Range Slider component into a React application. It uses refs for DOM manipulation and state management, and demonstrates listening to the 'change' event to update React state.
```jsx
import React, { useState, useEffect, useRef } from 'react';
import RangeSlider from 'svelte-range-slider-pips';
export default function MyComponent() {
const [values, setValues] = useState([25, 75]);
const sliderRef = useRef();
const nodeRef = useRef();
useEffect(() => {
if (!sliderRef.current) {
sliderRef.current = new RangeSlider({
target: nodeRef.current,
props: {
values: values,
pips: true,
first: 'label',
last: 'label',
range: true,
min: 0,
max: 100,
step: 5
}
});
sliderRef.current.$on('change', (e) => {
setValues(e.detail.values);
});
}
}, []);
function handleUpdate() {
const newVals = [values[0] + 10, values[1] + 10];
setValues(newVals);
sliderRef.current.$set({ values: newVals });
}
return (
Values: {values.join(' - ')}
);
}
```
--------------------------------
### Initialize Range Slider with Pips (JavaScript)
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/tests/vanilla/umd.html
This snippet shows how to create and initialize a RangeSliderPips component in JavaScript. It selects a target element, sets initial properties like values, pips, labels, and range, and then listens for change events to update an output element.
```javascript
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
// create and initialise the slider
const slider = document.querySelector('.my-slider');
const rangeSliderPips = new RangeSliderPips({
target: slider,
props: {
values: [-7, 7],
pips: true,
first: 'label',
last: 'label',
range: true,
min: -10,
max: 10
}
});
// listen for changes to the slider and update the output
const output = document.querySelector('#value-output');
rangeSliderPips.$on('change', function (e) {
output.innerHTML = e.detail.values;
});
}
};
```
--------------------------------
### Import Svelte Range Slider Pips as JS Module
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Demonstrates how to import the Svelte Range Slider Pips component as a JavaScript module and instantiate it with target DOM element and props. This approach is suitable for vanilla JS, Vue, and React applications using ES module imports.
```javascript
import RangeSlider from './node_modules/svelte-range-slider-pips/dist/svelte-range-slider-pips.mjs';
var mySlider = new RangeSlider({
target: node, // js reference to a DOM element
props: { values: [50], pips: true }
});
```
--------------------------------
### Basic Usage in Svelte 4
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Demonstrates the fundamental usage of the RangeSlider component within a Svelte 4 application. It imports the component and renders it with initial values and pips enabled.
```svelte
```
--------------------------------
### Svelte Range Slider Pips Configuration
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Configuration options for the svelte-range-slider-pips component.
```APIDOC
## Svelte Range Slider Pips Properties
This section details the various properties available for the svelte-range-slider-pips component.
### Properties
- **first** (`Boolean`/`String`) - Optional - Default: `false`. Whether to show a pip or label for the first value on the slider. Use `first='label'` to display the value as a label.
- **last** (`Boolean`/`String`) - Optional - Default: `false`. Whether to show a pip or label for the last value on the slider. Use `last='label'` to display the value as a label.
- **rest** (`Boolean`/`String`) - Optional - Default: `false`. Whether to show a pip or label for all other values. Use `rest='label'` to display the value as a label.
- **all** (`Boolean`/`String`) - Optional - Default: `false`. Whether to show a pip or label for all values. This is equivalent to combining `first`, `last`, and `rest`. Use `all='label'` to display the value as a label.
- **prefix** (`String`) - Optional - Default: `""`. A string to prepend to all displayed values.
- **suffix** (`String`) - Optional - Default: `""`. A string to append to all displayed values.
- **limits** (`Array`) - Optional - Default: `[0, 100]`. An array of two numbers to set limits on the slider handles. This overrides `min` and `max` for handle positioning but uses them for range display.
- **reversed** (`Boolean`) - Optional - Default: `false`. Reverses the orientation of min/max values.
- **hoverable** (`Boolean`) - Optional - Default: `true`. Enables hover styles for handles and pips/values.
- **disabled** (`Boolean`) - Optional - Default: `false`. Disables slider interactions and events.
- **id** (`String`) - Optional - Default: `""`. Assigns a unique ID to the slider for CSS styling.
- **class** (`String`) - Optional - Default: `""`. Adds custom CSS classes to the slider.
- **style** (`String`) - Optional - Default: `undefined`. Allows passing CSS variables or style declarations directly to the slider.
- **darkmode** (`False`/`"auto"`/`"force"`) - Optional - Default: `false`. Set to `"auto"` for automatic system dark mode detection, or `"light"` or `"dark"` to force a specific mode.
- **ariaLabels** (`Array`) - Optional - Default: `[]`. An array of strings to be used for the `aria-label` attribute on the slider handles.
- **formatter** (`Function`) - Optional - Default: `(v,i,p) => v`. A function to re-format values before they are displayed. `v` is the value, `i` is the pip index, and `p` is the percentage.
- **handleFormatter** (`Function`) - Optional - Default: `formatter`. A function to re-format values on the handle/float before they are displayed. Defaults to the `formatter` function. `v` is the value, `i` is the handle index, and `p` is the percentage.
### Example Usage
```svelte
Math.round(v)}
/>
```
```
--------------------------------
### Configure Spring Animation in Svelte
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Customize handle animation behavior using spring physics parameters like stiffness and damping. This configuration is applied directly within Svelte components using the `spring` and `springValues` props.
```svelte
```
--------------------------------
### Integrate Svelte Range Slider with jQuery
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Use the slider component within legacy applications that rely on jQuery. This involves including the necessary JavaScript files and instantiating the slider imperatively using the `RangeSliderPips` class.
```html
Values: 25, 75
```
--------------------------------
### Vue.js Integration with Watchers
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Explains how to embed the Svelte Range Slider component within a Vue.js application. It utilizes `ref` for DOM referencing, `onMounted` for initialization, and `watch` for synchronizing Vue's reactive state with the slider's properties.
```vue
```
--------------------------------
### Svelte Range Slider Pips Styling with CSS Variables
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/README.md
Illustrates how to style the Svelte Range Slider Pips component using CSS variables and the `font-size` property. Customization of colors and element dimensions can be achieved through these CSS properties. The `id` prop can be used for more specific targeting. Note the CSS class name prefixing with 'rs' in v4.
```css
/* Example of overriding default styles */
.rangeSlider {
--rs-bg-color: #e0e0e0;
--rs-progress-color: #4caf50;
--rs-handle-color: #2196f3;
font-size: 16px; /* Controls the scale of the slider elements */
}
/* Targeting a specific slider using its id */
#my-unique-slider .rangeSlider {
--rs-handle-color: #ff9800;
}
```
--------------------------------
### Svelte Range Slider: Pip Display Configuration
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Controls which pips and labels are displayed using 'first', 'last', 'rest', and 'all' properties. This allows fine-grained control over the visibility of markers and their labels on the slider.
```svelte
```
--------------------------------
### Update Slider Values Programmatically (JavaScript)
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Update slider values and other properties dynamically after initialization using the `$set` method. This is useful for controlling the slider state based on application logic or user interactions in vanilla JavaScript or framework integrations.
```javascript
const slider = new RangeSliderPips({
target: document.querySelector('#slider'),
props: { values: [50], pips: true }
});
// Update values programmatically
slider.$set({ values: [75] });
// Update multiple props at once
slider.$set({
values: [25, 75],
range: true,
step: 5
});
```
--------------------------------
### Svelte Range Slider: Limits and Constraints
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Restricts handle movement to a specific range within the slider using the 'limits' prop, which accepts an array of two numbers defining the minimum and maximum allowed values for the handles.
```svelte
```
--------------------------------
### Svelte Range Slider: Step Function with Custom Intervals
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Defines step intervals for snapping values to specific increments using the 'step' prop. This ensures that the slider values adhere to predefined increments.
```svelte
```
--------------------------------
### Range Mode with Pushy Handles in Svelte
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Configures a Svelte range slider to operate in 'range' mode with 'pushy' handles, where handles maintain a minimum and maximum distance. Includes label display for the first and last handles, and pips.
```svelte
```
--------------------------------
### Svelte Range Slider: Accessibility with ARIA Labels
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Provides descriptive ARIA labels for screen reader support using the 'ariaLabels' prop. This ensures better accessibility for users relying on assistive technologies.
```svelte
```
--------------------------------
### Svelte Range Slider: Custom Value Formatting with Currency
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Applies custom formatters to display slider values with specific formats, such as currency symbols and locale-specific number formatting. The 'formatter' prop accepts a function that receives the value, index, and percentage.
```svelte
```
--------------------------------
### Enable Range Float Display
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Demonstrates enabling the `rangeFloat` property to display the values between the range slider handles. This feature respects existing `prefix` and `suffix` properties and works with regular and reversed ranges.
```svelte
```
--------------------------------
### Control Float Precision in Svelte
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Set the decimal precision for handling floating-point values accurately. The `precision` prop defines the number of decimal places for displayed values and step increments, useful for financial or scientific applications.
```svelte
```
--------------------------------
### Light Theme CSS Variables for Svelte Range Slider
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Defines the CSS custom properties used for theming the Svelte Range Slider component in its light mode. These variables control the accent colors, base colors, background, and foreground.
```css
:root {
--slider-accent: #4a40d4;
--slider-accent-100: #838de7;
--slider-base: #99a2a2;
--slider-base-100: #b9c2c2;
--slider-bg: #d7dada;
--slider-fg: #3f3e4f;
}
```
--------------------------------
### CSS Variables for Dark Theme
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Defines CSS variables for customizing the dark theme of the range slider. These variables control accent colors, base colors, and background/foreground colors in dark mode.
```css
--slider-dark-accent: #6070fc;
--slider-dark-accent-100: #7a7fab;
--slider-dark-base: #82809f;
--slider-dark-base-100: #595868;
--slider-dark-bg: #3f3e4f;
--slider-dark-fg: #d7dada;
```
--------------------------------
### Svelte Range Slider: Dark Mode Support
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Enables automatic dark mode detection or forces a specific theme using the 'darkmode' prop. Set to 'auto' for detection or 'true'/'false' to force a theme.
```svelte
```
--------------------------------
### Enable Dark Mode in Svelte Range Slider
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Demonstrates how to enable dark mode for the Svelte Range Slider component using the `darkmode` prop. It shows options for disabling dark mode, automatically matching the system's preference, and forcing dark mode.
```svelte
```
--------------------------------
### Svelte Range Slider: Custom CSS Styling
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Applies custom styles and CSS variables for complete visual customization of the slider. This includes setting an ID, class, and inline styles or CSS variables for elements like the range and handles.
```svelte
```
--------------------------------
### CSS: Update Float Positioning for Svelte Range Slider
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Illustrates the CSS changes required for updating float element positioning in the Svelte range slider component. It shows how to transition from using 'transform: translate()' to the 'translate' CSS property, which is necessary due to component updates in v4 for better performance and compatibility.
```css
/* Before (v3) */
.rangeSlider .rangeHandle.active .rangeFloat {
transform: translate(-50%, -10px);
}
/* After (v4) */
.rangeSlider .rangeHandle.rsActive .rangeFloat {
translate: -50% -10px 0.01px;
}
```
--------------------------------
### Svelte Range Slider: Floating Labels
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Displays floating labels above the active handles, showing their current values. Enable this feature with the 'float' and 'rangeFloat' props.
```svelte
```
--------------------------------
### Svelte: Control Range Slider Animations and Custom Classes
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Shows how to control the animation of slider handles and apply custom CSS classes to a Svelte range slider. The 'spring' property defaults to true and disables animations when set to false. The 'class' property allows adding custom CSS classes to the base slider element for styling or framework integration.
```svelte
```
--------------------------------
### Svelte Range Slider: Draggable Range Area
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Enables users to drag the entire range area, shifting both handles simultaneously. This feature requires the 'range' and 'draggy' props to be enabled.
```svelte
```
--------------------------------
### Svelte Range Slider: Reversed Direction
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Reverses the standard min/max orientation, positioning higher values on the left (for horizontal sliders) or bottom (for vertical sliders). Use the 'reversed' prop for this functionality.
```svelte
```
--------------------------------
### Svelte Range Slider: Vertical Orientation
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Renders the slider in a vertical orientation, with lower values positioned at the bottom. This is achieved by setting the 'vertical' prop.
```svelte
```
--------------------------------
### Svelte Range Slider: Disabled State
Source: https://context7.com/simeydotme/svelte-range-slider-pips/llms.txt
Disables user interactions with the slider while maintaining its visual display. The 'disabled' prop can be a boolean, and its state can be toggled dynamically.
```svelte
```
--------------------------------
### Svelte: Control Range Slider Hover Effects with Disabled State
Source: https://github.com/simeydotme/svelte-range-slider-pips/blob/main/docs/upgrade.md
Demonstrates how to control hover effects on a Svelte range slider based on its 'hoverable' and 'disabled' states. Hover effects are only visible when 'hoverable' is true and the slider is not disabled. This affects both handle and range bar hover states.
```svelte
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.