@molecule/app-price-range-slider-svelte

Feature · price-range-slider · App (browser) · v1.1.4 · Apache-2.0

Single- or dual-handle range slider with formatted labels

npm install @molecule/app-price-range-slider-svelte

npm · Source on GitHub

How it works

@molecule/app-price-range-slider-svelte is a ready-made price-range-slider feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { PriceRangeSlider } from '@molecule/app-price-range-slider-svelte'

  let range = $state<[number, number]>([50, 500])
</script>

<PriceRangeSlider
  min={0}
  max={1000}
  value={range}
  onChange={(next) => (range = next)}
  step={10}
  formatValue={(n) => `$${n}`}
>
  {#snippet label()}
    Price range
  {/snippet}
</PriceRangeSlider>

Works with: @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte numeric min/max range picker.

Svelte counterpart of @molecule/app-price-range-slider-react — the same props (React names) and the same DOM for the same input. Exports <PriceRangeSlider> — TWO native <input type="range"> controls rendered side by side (min slider + max slider) with formatted endpoint labels. The handles clamp against each other so low <= high always holds. It is not a single-track dual-thumb slider.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { PriceRangeSlider } from '@molecule/app-price-range-slider-svelte'

  let range = $state<[number, number]>([50, 500])
</script>

<PriceRangeSlider
  min={0}
  max={1000}
  value={range}
  onChange={(next) => (range = next)}
  step={10}
  formatValue={(n) => `$${n}`}
>
  {#snippet label()}
    Price range
  {/snippet}
</PriceRangeSlider>

Type

feature

Installation

npm install @molecule/app-price-range-slider-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

PriceRangeSliderProps

Props accepted by the PriceRangeSlider component.

interface PriceRangeSliderProps {
  /** Minimum possible value. */
  min: number
  /** Maximum possible value. */
  max: number
  /** Current [low, high] tuple. If only one value is relevant, set low === min. */
  value: [number, number]
  /** Called whenever either handle moves. */
  onChange?: (value: [number, number]) => void
  /** Step increment. Defaults to 1. */
  step?: number
  /** Called to format each endpoint label — defaults to USD currency formatting. */
  formatValue?: (n: number) => string
  /** Optional label above, as a snippet. */
  label?: Snippet
  /** Extra classes. */
  className?: string
}

Constants

PriceRangeSlider

const PriceRangeSlider: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-svelte ^3.13.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-svelte
  • @molecule/app-ui
  • @molecule/app-ui-svelte
  • svelte

The default formatValue renders US-style dollars ($1,000) — always pass your own formatter for non-USD apps. The two sliders' aria-labels ("Minimum"/"Maximum") translate through t() (priceRangeSlider.aria.minimum/priceRangeSlider.aria.maximum), so they follow the active locale. Requires a wired ClassMap bond (getClassMap()). The optional label is a snippet.

Translations

Translation strings are provided by @molecule/app-locales-price-range-slider.