Skip to main content
Clever Ops

Slide Rule

A working slide rule for React, drag the slide and the glass runner across true log scales and read the product off the hairline. Two real ARIA sliders, Tailwind token ink.

Preview & code

Loading Slide Rule preview

Installation

pnpm dlx shadcn@latest add @cleverui/slide-rule

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { SlideRule } from '@/components/ui/slide-rule'
Exampletsx
import { SlideRule } from '@/components/ui/slide-rule'

export default function SlideRuleDemo() {
  return (
    <div className="mx-auto w-full max-w-3xl px-4 py-10 sm:px-6 sm:py-14">
      <p className="mb-4 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground sm:text-xs">
        Spectacle · log instrument
      </p>
      <h2 className="mb-6 text-2xl font-semibold tracking-tight text-balance sm:text-3xl">
        Align the scales. Read the hairline.
      </h2>
      <SlideRule
        defaultFactor={2}
        defaultOperand={3.2}
        caption="MANNHEIM PATTERN · C / D"
        ariaLabel="Slide rule"
      />
      <p className="mt-4 text-sm leading-relaxed text-muted-foreground">
        Drag the C slide to set the factor, then the glass runner along C for the
        operand. The product is pure log geometry, Tab between handles, arrows
        nudge by a hundredth of a decade.
      </p>
    </div>
  )
}

API reference

SlideRule accepts the following props.

PropTypeDefaultDescription
defaultFactornumber2initial C-scale factor (clamped 1-10)
defaultOperandnumber3.2initial runner position on the C scale (clamped 1-10)
captionstring'MANNHEIM PATTERN · C / D'mono micro-label under the rule
ariaLabelstring'Slide rule'accessible name for the instrument group

…plus everything from React.HTMLAttributes<HTMLDivElement>: className, event handlers, aria attributes and the rest pass straight through.

Frequently asked questions

How do I install the Slide Rule component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/slide-rule`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Slide Rule require?

Slide Rule uses motion on top of React and Tailwind CSS. You don't need to install it manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Slide Rule to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services