CSS Range Slider with Ticks
A stepped range slider that snaps to five values, with tick marks and labels drawn under the track.
<label class="range-ticks">
<span>Team size</span>
<input type="range" min="0" max="4" step="1" value="2">
<span class="range-ticks-scale" aria-hidden="true">
<span>1</span><span>5</span><span>10</span><span>25</span><span>50+</span>
</span>
</label>
.range-ticks {
--thumb: 20px;
display: grid;
gap: 8px;
width: 260px;
color: #422006;
font: 600 13px system-ui, sans-serif;
}
.range-ticks input {
width: 100%;
height: var(--thumb);
margin: 0;
background:
linear-gradient(#fde68a, #fde68a) center / calc(100% - var(--thumb)) 4px no-repeat,
repeating-linear-gradient(90deg, #ca8a04 0 2px, transparent 0 calc((100% - 2px) / 4)) calc(var(--thumb) / 2 - 1px) 100% / calc(100% - var(--thumb) + 2px) 6px no-repeat;
-webkit-appearance: none;
appearance: none;
cursor: pointer;
}
.range-ticks input::-webkit-slider-thumb {
width: var(--thumb);
height: var(--thumb);
border: 3px solid #ca8a04;
border-radius: 50%;
background: #fff;
-webkit-appearance: none;
appearance: none;
}
.range-ticks input::-moz-range-thumb {
box-sizing: border-box;
width: var(--thumb);
height: var(--thumb);
border: 3px solid #ca8a04;
border-radius: 50%;
background: #fff;
}
.range-ticks input:focus-visible {
outline: 2px solid #ca8a04;
outline-offset: 4px;
}
.range-ticks-scale {
display: flex;
justify-content: space-between;
margin: 0 calc(var(--thumb) / 2 - 8px);
color: #a16207;
font-size: 11px;
font-weight: 500;
}
.range-ticks-scale span {
width: 16px;
text-align: center;
}
About this CSS Range Slider with Ticks
This CSS Range Slider with Ticks is 58 lines of pure CSS (1.3 KB) with no JavaScript and no dependencies. It uses linear gradients, CSS Grid, Flexbox and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
Change these custom properties to restyle the range slider with ticks without touching the rest of the CSS:
| Property | Default |
|---|---|
--thumb | 20px |
How to use this range slider with ticks
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.range-ticksclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.