Skip to content

Target Slider

Reduction target picker: a thick rounded sage range (0–60%) with tick labels and a “science-aligned” marker, showing the resulting tonnes and a gentle verdict.

organic-soft/ui/target-slider
Open ↗

Source

"use client";

import { useId, useState } from "react";
import { cn } from "@/lib/utils";

export interface TargetSliderProps {
  label?: string;
  /** Baseline emissions (tCO₂e). */
  baseline?: number;
  defaultValue?: number;
  /** Recommended reduction %. */
  recommended?: number;
  onValueChange?: (percent: number) => void;
  className?: string;
}

/** Reduction target picker: a thick rounded sage range (0–60%) with tick labels and a “science-aligned” marker, showing the resulting tonnes and a gentle verdict. */
export function TargetSlider({
  label = "Reduction target for 2030",
  baseline = 284,
  defaultValue = 30,
  recommended = 42,
  onValueChange,
  className,
}: TargetSliderProps) {
  const id = useId();
  const [v, setV] = useState(defaultValue);
  const verdict =
    v >= recommended
      ? "Science-aligned — lovely."
      : v >= recommended * 0.6
        ? "A solid start. Science suggests a little more."
        : "Gentle, but probably not enough.";
  return (
    <div className={cn("max-w-lg rounded-da-lg bg-da-surface p-6 text-da-surface-fg shadow-da-sm", className)}>
      <label htmlFor={id} className="font-da-display text-xl">
        {label}
      </label>
      <p className="mt-3" aria-live="polite">
        <span className="font-da-display text-5xl text-da-primary">−{v}%</span>{" "}
        <span className="font-da-mono text-sm text-da-muted-fg">→ {Math.round(baseline * (1 - v / 100))} tCO₂e</span>
      </p>
      <div className="relative mt-6">
        <input
          id={id}
          type="range"
          min={0}
          max={60}
          step={1}
          value={v}
          onChange={(e) => {
            setV(Number(e.target.value));
            onValueChange?.(Number(e.target.value));
          }}
          aria-valuetext={`${v}% reduction, ${verdict}`}
          className="da-focus h-3 w-full cursor-pointer appearance-none rounded-full bg-da-surface-2 accent-(--da-primary) [&::-webkit-slider-thumb]:size-6 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-4 [&::-webkit-slider-thumb]:border-da-surface [&::-webkit-slider-thumb]:bg-da-primary [&::-webkit-slider-thumb]:shadow-da-md"
          style={{ background: `linear-gradient(to right, var(--da-primary) ${(v / 60) * 100}%, var(--da-surface-2) ${(v / 60) * 100}%)` }}
        />
        <span aria-hidden className="absolute -top-2 h-7 w-0.5 rounded-full bg-da-secondary-fg" style={{ left: `${(recommended / 60) * 100}%` }} />
      </div>
      <div aria-hidden className="mt-2 flex justify-between font-da-mono text-xs text-da-muted-fg">
        {[0, 15, 30, 45, 60].map((t) => (
          <span key={t}>{t}%</span>
        ))}
      </div>
      <p
        className={cn(
          "mt-4 rounded-da-md px-4 py-2.5 text-sm",
          v >= recommended ? "bg-da-accent text-da-accent-fg" : "bg-da-secondary/60 text-da-secondary-fg",
        )}
      >
        {verdict}
      </p>
    </div>
  );
}

export default TargetSlider;

modules/organic-soft/ui/target-slider/index.tsx

Props

PropTypeDefaultDescription
labelstring—Label.
baselinenumber—Baseline emissions (tCO₂e).
defaultValuenumber—Default Value.
recommendednumber—Recommended reduction %.
onValueChange(percent: number) => void—Callback.
classNamestring—Extra classes on the root.

Other input variants in Organic Soft

Input in other art directions

Input

Labelled text field with hint, error state, leading icon, suffix slot and two sizes. The field presses into its shadow on focus; errors switch to a red stroke with an explicit message.

BrutalistInput

Number Stepper

Numeric input flanked by chunky yellow − / + buttons (disabled at bounds), big display-font value, optional unit suffix; clamps typed values to min/max.

BrutalistInput

OTP Input

One-time-code input: ruled digit squares (split 3+3 for six digits) that turn yellow and press in on focus; auto-advance, backspace and arrow navigation, paste of the full code, completion callback and error state.

BrutalistInput

Textarea

Labelled multi-line field with a live character counter chip that turns orange near the limit, hint and error states; presses into its shadow on focus.

BrutalistInput

Combobox

Autocomplete select: a glass pill input that filters a frosted listbox as you type, with arrow-key highlight, Enter to choose, Escape to close, hints and a check on the selection.

GlassInput

Input

Frosted text field with label, hint, error state, leading icon, trailing slot (button, kbd, unit), rounded or pill shape and two sizes. Focus brightens the glass and adds a soft violet halo.

GlassInput

Range Slider

Glass slider on Radix Slider: frosted track, primary→accent range, glowing gradient thumbs with value bubbles on hover/focus and tick labels; single value or range.

GlassInput

Tag Input

Glass chip input: type and press Enter or comma to add gradient chips, Backspace removes the last, × removes one; quick-add suggestion chips and a max counter.

GlassInput

Input

Hairline text field with label (auto "Optional" marker), hint, error with icon, leading icon, text prefix, trailing slot (unit, kbd) and indigo focus ring. Two sizes.

MinimalInput

Search Input

Search field with leading icon, “/” keycap hint that focuses the field, clear button (Escape clears too) and a loading spinner state. Two sizes, controlled or uncontrolled.

MinimalInput

Select Menu

Labelled select built on Radix Select: bordered trigger with chevrons, portalled popover with optional icons, descriptions, groups, separators, disabled items and a check on the selected one.

MinimalInput

Switch Field

Settings row with label and description on the left and a Radix Switch on the right; plain (for divided lists) or bordered card that highlights when on. Disabled state.

MinimalInput

Checkbox Group

Settings checkboxes as ruled rows: square ink check boxes (native inputs), label and muted description; the whole row is clickable.

Mono CleanInput

Input

Underline field: mono uppercase label, a borderless input on a single bottom hairline that turns ink (2px) on focus, optional prefix, hint or red error.

Mono CleanInput

Search Input

Search field with live results: hairline-bordered input with icon and ⌘K hint; matches appear in a ruled list below with the query highlighted and a mono kind label; empty state included.

Mono CleanInput

Select Field

Native select styled as an underline field with a mono label and a custom chevron — reliable on every device and screen reader.

Mono CleanInput

Currency Input

Amount field with currency symbol prefix and an attached currency select; formats with thousands separators on blur, right-aligned mono digits.

Neo CorporateInput

File Upload

Receipt/document dropzone: dashed bordered area with upload icon, click-or-drag, file list with size, per-file size validation errors and remove buttons.

Neo CorporateInput

Input

Form field: label (with optional marker), bordered 40px input with leading/trailing adornments, blue focus ring, hint text or red error with aria-invalid.

Neo CorporateInput

Select Field

Labelled Radix Select styled as a bordered field: grouped options (e.g. GL accounts) with group headings, check on the selected item, portalled popover with data-da.

Neo CorporateInput

Checkbox List

Round-checkbox to-do list built on native checkboxes: bouncy mint ticks, strike-through when done, meta line per item and an “x of y” counter with a progress bar.

Soft FlatInput

Day Picker

Week-strip date picker: prev/next week arrows and seven rounded day pills (weekday + number) with task-load dots (red when full); the selected day fills periwinkle.

Soft FlatInput

Input

Soft text field: rounded tinted well that turns white with a thick periwinkle ring on focus, label, optional leading icon and suffix, hint or red error message.

Soft FlatInput

Radio Cards

Native radio group rendered as big pastel cards (emoji, title, text); the chosen card lifts with a periwinkle ring and a filled radio dot.

Soft FlatInput