Tick Slider new 刻度滑块 web

50

标本可交互,可以直接操作。

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Tick row刻度排 flex + 2px marks

    Evenly spaced marks that make up the track.

    均匀排列、组成轨道的细线。

    Prompt fragmentPrompt 片段

    40 thin vertical ticks spaced evenly

    40 根均匀排列的细竖线

  2. 2 Dark fill深色填充 value → count

    Marks up to the value turn dark.

    数值以内的刻度变深。

    Prompt fragmentPrompt 片段

    ticks below the value dark, the rest light grey

    数值以内的刻度深色,其余浅灰

  3. 3 Pointer lift指针抬升 Gaussian scaleY

    Marks near the pointer grow on a bell curve.

    指针附近的刻度按钟形曲线变高。

    Prompt fragmentPrompt 片段

    ticks near the pointer growing up to 55% on a bell curve

    指针附近的刻度按钟形曲线最多拉高 55%

  4. 4 Readout数字读数 role=slider

    The number beside it, kept in sync with the accessible value.

    旁边的数字,与无障碍数值保持一致。

    Prompt fragmentPrompt 片段

    a numeric readout matching aria-valuenow

    与 aria-valuenow 一致的数字读数

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Build a tick slider: 40 vertical ticks (2px wide, 24px tall) spaced evenly across the track with a numeric readout on the right. Value 0-100; ticks below value/100*40 are dark (#1d1f24), the rest light grey. Ticks near the pointer scale up on Y by up to 55% following a Gaussian with sigma about 2 ticks, fading in and out smoothly. Click or drag anywhere on the track (pointer capture) to set the value; the displayed number eases toward it. Make it accessible: role=slider, tabindex=0, aria-valuemin/max/now, arrow keys ±1, Shift+arrow ±10, Home/End. Stop the animation loop once settled.

做一个刻度滑块:轨道上均匀排 40 根竖刻度(宽 2px、高 24px),右边显示数字。数值 0–100;value/100×40 以内的刻度为深色(#1d1f24),其余浅灰。指针附近的刻度按高斯曲线(σ 约 2 根)沿 Y 方向放大,最多 55%,平滑出现和消失。在轨道任意位置点击或拖动(指针捕获)设置数值,显示的数字缓动到新值。做好无障碍:role=slider、tabindex=0、aria-valuemin/max/now,方向键 ±1,Shift+方向键 ±10,Home/End。数值稳定后停止动画循环。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my tick slider. Check that the value maps from the pointer position relative to the track (not the page); dragging keeps working outside the track via pointer capture; dark ticks match the value exactly at 0 and 100; the hover growth uses transform so the row does not reflow; the number shown and aria-valuenow agree; arrow keys work when focused and there is a visible focus ring; and the requestAnimationFrame loop stops when nothing is changing. The symptom:

调试我的刻度滑块。检查:数值是否按指针相对轨道(而不是页面)的位置换算;拖出轨道后是否靠指针捕获继续生效;0 和 100 时深色刻度数量是否正好对应;悬停放大是否用 transform,没有引起整行重排;显示的数字和 aria-valuenow 是否一致;获得焦点时方向键是否可用,且有可见的焦点框;没有变化时 requestAnimationFrame 循环是否停止。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
ARIA role="slider" + aria-valuenow a custom slider needs the slider role, value and arrow-key support自定义滑块需要 slider 角色、数值和方向键支持
CSS transform: scaleY(var(--s)) grow ticks without changing layout用 transform 拉高刻度,不改变布局
JS Math.exp(-d² / 2σ²) a bell curve around the pointer sets each tick's growth以指针为中心的钟形曲线决定每根刻度拉高多少
HTML <input type="range"> the native alternative when a custom look is not needed不需要自定义外观时用原生控件

See also相关词条

我的参考集

组合知名网站、UI 元素、视觉风格和平面设计案例,导出给 AI。

你的下一份设计,从这里开始。

在任意案例旁点击「加入参考」,就能把品牌、组件、风格和平面设计案例组合成一份 AI 设计说明。

搜索参考库Search the library

输入关键词,搜索所有参考。