Ruler

A fine ruler slider whose ticks lift and magnify beneath a small glass lens.

isomer.sh/effects/ruler

Knobs

Continue on iPhone
Preset
#98958E
#D3AB78
1.10
56.0
Light1
0.65
Shape2
8.0
28.0
Motion2
1.40
0.72
Texture1
0.22
Still frame

What reduced motion shows: 5 s.

Install

Code

components/isomer/ruler.tsx
'use client';
// Generated by isomer. Do not edit by hand; run `isomer add` again to update. (from packages/react/src/Ruler.tsx)
// generated by packages/react/scripts/gen-components.mjs, do not edit
import type { CSSProperties } from 'react';
import { useIsomerCanvas, usePrefersReducedMotion, type Mount } from './useIsomerCanvas';
import { useLive, usePointer, type LiveSpec } from './live';
// @ts-ignore: the runtime is plain JS with no type declarations
import * as runtime from './ruler.js';

const { DEFAULTS, mount } = runtime as { DEFAULTS: RulerKnobs; mount: Mount };

export interface RulerKnobs {
  tickColor: string;
  accent: string;
  tickSpacing: number;
  magnification: number;
  lensWidth: number;
  trackHeight: number;
  weight: number;
  dampingRatio: number;
  lensGloss: number;
  grain: number;
  sliderValue: number;
  fromValue: number;
}

export interface RulerProps extends Partial<RulerKnobs> {
  className?: string;
  style?: CSSProperties;
  /** Render this one frame (seconds) and run no clock. Used by the parity tests. */
  time?: number;
  paused?: boolean;
  /** The clock stops at t = 5 and holds that frame. Draw t = 5 once when the user prefers reduced motion. Default true. */
  respectReducedMotion?: boolean;
  /** Keep each frame readable after it is shown, for canvas.toDataURL or readPixels. Read at mount. Default false. */
  preserveDrawingBuffer?: boolean;
  /**
   * Live inputs, when there is no `time` and the user does not prefer reduced motion: A press on the canvas
   * restarts the effect and flips `sliderValue`, starting from where its spring was. Default true.
   */
  live?: boolean;
}

/** Where each live input comes from: the spec's `live` block. */
const LIVE: LiveSpec<RulerKnobs> = {
  inputs: [],
  follow: { stiffness: 1200.0, dampingRatio: 1.0 },
  event: { trigger: 'press', state: 'sliderValue', from: 'fromValue', spring: k => ({ stiffness: 110 / k.weight, dampingRatio: k.dampingRatio }) },
  settleAt: 5.0,
};

export const rulerDefaults: Readonly<RulerKnobs> = DEFAULTS;

export function Ruler({ className, style, time, paused, respectReducedMotion, preserveDrawingBuffer, live, ...props }: RulerProps) {
  const knobs = { ...DEFAULTS };
  for (const k of Object.keys(DEFAULTS) as (keyof RulerKnobs)[]) {
    const v = props[k];
    if (v !== undefined) (knobs as Record<string, unknown>)[k] = v;
  }
  // A fixed time is test mode, and reduced motion draws the poster: either way the live inputs stay off (no
  // sensors, no pointer, no events) and the knobs render as given.
  const reduced = usePrefersReducedMotion() && respectReducedMotion !== false;
  const inputs = useLive(LIVE, mount, knobs, time === undefined && live !== false && !reduced);
  const ref = useIsomerCanvas({ mount: inputs.mount, knobs, time, paused, respectReducedMotion, preserveDrawingBuffer, posterTime: 5.0, settleAt: inputs.enabled ? undefined : 5.0 });
  usePointer(ref, inputs);
  return <canvas ref={ref} className={className} style={{ display: 'block', width: '100%', height: '100%', ...style }} />;
}

Parity

iPhone 17 Pro simulator, iOS 26.3.1 against Chromium headless + SwiftShader, 15 October 2026.