Slider: marker data-state ignores origin "center" / "end"

Open Beginner friendly
#3,705 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@itisrmk is already working on this.

Since Dec 1, 2026.

  • #3714 by @itisrmk — open
  • #3723 by @abu-tahir-0 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
80/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
frontend

Research direction

Start with getMarkerProps and getRangeOffsets in slider.connect.ts, then run the provided repro.mjs script to compare marker states with the filled range. Add or update slider marker tests to cover single-value sliders with origin set to start, center, and end. The work is done when each marker’s state reflects whether it lies within the filled range for every origin.

Written by the indexing model from the issue text.

Description

🐛 Bug report

With origin: "center" or origin: "end", the slider fills the track from the origin to the thumb, but the markers still get their data-state from comparing their value with the slider value only. So marker styling that follows the docs' selector ([data-part="marker"][data-state="under-value"] for the filled part) colours the wrong markers.

For a centred slider at 70 the track is filled from 50 to 70, yet markers 0 to 40 report under-value like the ones on the filled part. At 30 it gets worse: the track is filled from 30 to 50, and marker 40, which sits on the filled part, reports over-value. With origin: "end" it's fully inverted.

Range sliders (two thumbs) are fine, the markers between the thumbs report at-value.

💥 Steps to reproduce

  1. Create a single-value slider with origin: "center" and defaultValue: [70]
  2. Add markers at 0, 10, ... 100
  3. Read each marker's data-state and compare it with --slider-range-start / --slider-range-end on the root

💻 Link to reproduction

No sandbox, but it needs no DOM, so here's a plain Node script (npm i @zag-js/slider @zag-js/vanilla, then node repro.mjs):

import * as slider from "@zag-js/slider"
import { VanillaMachine, normalizeProps } from "@zag-js/vanilla"

// headless: no DOM needed to read the props
const fakeRoot = { getElementById: () => null, querySelector: () => null, querySelectorAll: () => [] }

for (const [origin, value] of [["start", 70], ["center", 70], ["center", 30], ["end", 70]]) {
  const machine = new VanillaMachine(slider.machine, { id: "s", origin, defaultValue: [value], getRootNode: () => fakeRoot })
  machine.start()
  const api = slider.connect(machine.service, normalizeProps)
  const root = api.getRootProps().style
  const markers = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100].map((v) => `${v}:${api.getMarkerProps({ value: v })["data-state"]}`)
  console.log(`origin=${origin} value=${value} range-start=${root["--slider-range-start"]} range-end=${root["--slider-range-end"]}`)
  console.log("  " + markers.join(" "))
  machine.stop()
}

Output with 1.49.0:

origin=start value=70 range-start=0% range-end=30%
  0:under-value 10:under-value 20:under-value 30:under-value 40:under-value 50:under-value 60:under-value 70:at-value 80:over-value 90:over-value 100:over-value
origin=center value=70 range-start=50% range-end=30%
  0:under-value 10:under-value 20:under-value 30:under-value 40:under-value 50:under-value 60:under-value 70:at-value 80:over-value 90:over-value 100:over-value
origin=center value=30 range-start=30% range-end=50%
  0:under-value 10:under-value 20:under-value 30:at-value 40:over-value 50:over-value 60:over-value 70:over-value 80:over-value 90:over-value 100:over-value
origin=end value=70 range-start=70% range-end=0%
  0:under-value 10:under-value 20:under-value 30:under-value 40:under-value 50:under-value 60:under-value 70:at-value 80:over-value 90:over-value 100:over-value

The marker states are identical for start, center and end, while the filled range differs.

🧐 Expected behavior

A marker's state tells whether it sits on the filled part of the track, the same way the range does. For origin: "center" at 70, markers 50 to 60 are on the filled part and 0 to 40 and 80 to 100 aren't. For origin: "end" at 70, markers 80 to 100 are on the filled part.

🧭 Possible Solution

getMarkerProps in slider.connect.ts compares props.value with first(sliderValue) and last(sliderValue). For a single value it could compare with the range the origin produces (origin value to thumb), the same bounds getRangeOffsets uses. If changing what under-value / over-value mean feels too breaking, a separate attribute like data-in-range would work for us too.

🌍 System information

Software Version(s)
Zag Version @zag-js/slider 1.49.0 (also 1.47.0, via @ark-ui/svelte)
Browser any (reproduced headless in Node 24)
Operating System any

📝 Additional information

We ran into it building Material 3's centred slider, where stop indicators on the active track use a different colour than the ones on the inactive track.

Dominant language
TypeScript
Stars
5.3k
Forks
320
Avg merge
1d 22h
Merged PRs (30d)
60

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from chakra-ui/zag

All issues in chakra-ui/zag

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.