Skip to content

Pull Cord

Pro

A theme switch you pull like a lamp cord: drag the brass bead down and let go, and the rope springs back as the page goes light or dark.

  • Base UI
  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 11, 2026 · Pro license

Playground

Loading the preview

Props

Needs your Pro API key in GELATIN_UI_PRO_TOKEN. Set it up

Pro itemAPI key required

Pull Cord needs a Pro API key

Try the live preview for free. With Pro, the add command above puts the source in your project.

Files it adds
21
More Pro items, one API key
+327
Your coding agent runs it
1 cmd

$79$129once, for life

Already have Pro? Sign in to set up your API key.

Wire the value to your theme, and compose the glow, the cord, and the handle at the top edge of the page.

theme-cord.tsx

PullCord

<div>
PropTypeDefaultDescription
value"dark""light"—The theme the cord shows. Controlled: a pull asks for the other value.
defaultValue"dark""light""light"
onValueChange—Called at the moment of the switch, with the new value.
disabledbooleanfalseStops new pulls. The bead still swings back to rest.
lengthnumberPULL_CORD.lengthThe rest length of the rope in px, from the top edge to the bead. Default 96.
driverRef—Drives a pull from code (DragDriver, no item): a staged scene or a test takes the bead, and the rope, the switch, and the spring back work as for a finger.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

PullCordGlow

<div>
PropTypeDefaultDescription
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

PullCordCord

<svg>
PropTypeDefaultDescription
...props<svg> attributes—Every other attribute goes to the <svg>, with a ref.

PullCordHandle

<button>
PropTypeDefaultDescription
classNamestring—
styleCSSProperties—
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
nativeButtonbooleantrueWhether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).
...props<button> attributes—Every other attribute goes to the <button>, with a ref.
  • Wire value and onValueChange to the theme store of the app, for example next-themes setTheme.
  • Hang it from a top edge with absolute top-0, and leave length + 44px of room under the edge.
  • Give PullCordHandle an aria-label that names what the switch turns on, for example "Night reading".
  • For a plain theme switch in a settings row, use a Theme Switch.
  • For a choice of light, dark, and system, use a Theme Picker.
  • For an on and off setting in a form, use a Switch.
TabMoves the focus to the bead.
EnterorSpacePlays one pull and switches between light and dark.

The bead is a switch with a 44px target. It is checked when the value is dark.

Enter and Space play the pull, so the keyboard gets the same switch as a drag.

Pull
elastic · the rope stretches under the finger with soft limits, 84px down and 10px up
Release
elastic · the rope springs back with the release speed and one bounce, where it goes slack
Swing
sway · the bead swings to the side and back after a release or a hover
Tap or key
indicator · the bead goes down 52px, switches, and springs back
Glow
reveal · switching to light flashes the warm glow, then it rests at 55%
  1. AddedPull Cord.
Open the release