Slosh Slider <mv-slosh-slider>

채움 영역이 액체인 슬라이더입니다. 손잡이는 손가락 아래에서 단단하게 고정되어 있고, 액체가 부드러운 스프링으로 그 뒤를 쫓으며 끝에 부딪히고 속도에 따라 기울고 출렁입니다.

작동 방식

채움이 액체인 슬라이더: 핸들은 손가락 아래에서 단단히 고정되고, 액체는 부드러운 스프링으로 핸들을 뒤쫓으며 끝 지점에 부딪히고, 속도에 따라 기울고 출렁입니다. 완전한 폼 필드(키보드, ARIA, 초기화)이며, 세로로 두면 탱크가 됩니다.

카테고리폼
유형Web Component (<mv-slosh-slider>)
상태안정
Keywordsslider, range, liquid, physics, spring, gauge, tank, form-associated, tactile

When to use

  • A playful or tactile product wants a slider whose liquid fill reacts to drag speed
  • A level such as volume, water intake or a fill ratio reads well as a vertical tank
  • A marketing or onboarding page wants a memorable form control that still submits a value

Avoid when

  • A dense settings screen needs a sober slider, two thumbs or labeled tick marks → use Slider instead
  • Another expressive style fits better, like a wave, ruler or value bubble → use Range FX instead
  • Many sliders appear on one page; the per-slider spring physics adds noise and cost

설치

node scripts/add.mjs slosh-slider --out ./src/marvelous

Marvelous UI MCP 서버를 사용하는 AI 에이전트: install_components({ slugs: ["slosh-slider"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).

복사되는 파일(의존성 포함): tokens/tokens.css, core/base.css, core/dom.js, core/element.js, core/form.js, core/motion.js, core/observe.js, components/slosh-slider/slosh-slider.js, components/slosh-slider/slosh-slider.css.

사용법

기본 마크업입니다. 여기서 시작해 속성, data-*, CSS 변수로 커스터마이즈하세요:

<form id="mv-slosh-slider-demo" style="display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2rem 2.5rem;align-items:end;width:100%;max-width:640px">
  <div style="display:grid;gap:1.4rem">
    <mv-slosh-slider label="Volume" name="volume" value="64" suffix="%"></mv-slosh-slider>
    <mv-slosh-slider label="Monthly budget" name="budget" min="0" max="2000" step="50" value="850" prefix="$" slosh="0.85" style="--mv-slosh-slider-color:var(--mv-success);--mv-slosh-slider-color-2:color-mix(in oklch,var(--mv-success),black 15%)"></mv-slosh-slider>
    <mv-slosh-slider label="Brightness (classic)" name="brightness" value="30" suffix="%" slosh="0" style="--mv-slosh-slider-height:1.75rem"></mv-slosh-slider>
  </div>
  <mv-slosh-slider label="Tank" name="water" orientation="vertical" value="70" suffix=" L" max="120" slosh="0.9" style="--mv-slosh-slider-color:var(--mv-info);--mv-slosh-slider-color-2:color-mix(in oklch,var(--mv-info),black 22%)"></mv-slosh-slider>
  <div style="grid-column:1/-1;display:flex;gap:.6rem;align-items:center;flex-wrap:wrap">
    <button class="mv-button" data-size="sm" type="submit">Submit</button>
    <button class="mv-button" data-size="sm" data-variant="outline" type="reset">Reset</button>
    <output id="mv-slosh-slider-demo-out" style="font-size:.8rem;color:var(--mv-fg-muted)"></output>
  </div>
</form>
<script type="module">
  const form = document.getElementById("mv-slosh-slider-demo");
  const out = document.getElementById("mv-slosh-slider-demo-out");
  form.addEventListener("submit", (e) => {
    e.preventDefault();
    out.textContent = [...new FormData(form)].map(([k, v]) => `${k} = ${v}`).join(" · ");
  });
</script>

API

Attributes

Name유형DefaultDescription
labelstringVisible label (and accessible name).
namestringForm field name.
valuenumberInitial value (also used on reset).
min / max / stepnumber0 / 100 / 1Bounds and step (the step sets the displayed precision).
sloshnumber0.6Inverse viscosity: 0 = classic slider, 1 = very fluid liquid (softer, less damped).
orientationhorizontal | verticalhorizontalvertical: a tank that fills from the bottom, with a sloshing horizontal surface.
prefix / suffixstringText around the displayed and announced value (e.g. suffix="%").
hide-valuebooleanHides the displayed value (it is still announced).
disabled / requiredbooleanForm states (a disabled fieldset is respected).

Properties

Name유형Description
valuestringValue (a string, like an input).
valueAsNumbernumberNumeric value.

Events

NameDescription
inputOn every change while dragging or using the keyboard.
changeOn release or after a key press.

CSS variables

NameDefaultDescription
--mv-slosh-slider-color / --mv-slosh-slider-color-2accent / darkened accentLiquid gradient.
--mv-slosh-slider-trackvar(--mv-bg-muted)Tube background.
--mv-slosh-slider-height2.75remThickness of the horizontal tube.
--mv-slosh-slider-width / --mv-slosh-slider-length4.75rem / 12remSize of the vertical tank.
--mv-slosh-slider-radiusfull (2xl when vertical)Tube radius.
--mv-slosh-slider-ratioSet by the component: position 0..1, for styling around it.

Accessibility

role=slider on the tube (focusable), aria-valuemin/max/now and formatted aria-valuetext; ←/→/↑/↓ (Shift ×10), Page↑/↓, Home/End. Form-associated (ElementInternals): submitted value, reset, disabled fieldset, <label for>. The liquid is decorative (SVG aria-hidden). Reduced motion: instant fill, no ripples. Forced colors: the tube is outlined, the liquid is Highlight and the handle CanvasText.

이 페이지는 AI로 번역되었습니다. 번역 문제 신고