Skip to content
VenusUI
Get started

Pull-Cord Lamp

A hanging lamp you switch by pulling its cord; it can toggle the page between light and dark mode.

Preview

Installation

npx shadcn@latest add @venusui/pull-cord-lamp

Run this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.

Files added to your project

Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.

  • @/components/ui/pull-cord-lamp.tsx

Usage

The code behind the preview above.

pull-cord-lamp-demo.tsx

import { PullCordLamp } from "@/components/ui/pull-cord-lamp"

export default function PullCordLampDemo() {
  return (
    <div className="flex min-h-[26rem] w-full flex-col items-center">
      <PullCordLamp controlsTheme label="Light (switches light and dark mode)" />
      <p className="mt-auto text-sm text-muted-foreground">Pull the cord to switch between light and dark.</p>
    </div>
  )
}

API reference

PropTypeDefaultDescription
controlsThemebooleanfalseSwitch the page between light (lamp on) and dark (lamp off) by toggling .dark on <html>.
on, defaultOnboolean—Controlled or initial state when not controlling the theme.
onToggle(on: boolean) => void—Called after each pull.
labelstring"Light"Accessible name for the cord.

All <div> props.

Requirements

  • React 19 and Tailwind CSS v4. The CLI adds the pull-cord-lamp-swing keyframes.
  • controlsTheme assumes shadcn's class-based dark mode (.dark on <html>).

Customization

  • With a theme library such as next-themes, leave controlsTheme off and call its setTheme from onToggle, so the choice is saved.
  • The light cone is a gradient under the bulb; change its color in the first div.

Accessibility

  • The cord is a switch with aria-checked; a click, tap, Enter or Space toggles it, so dragging is optional.
  • With reduced motion the lamp doesn't swing.

Troubleshooting

The theme switches back on reload.
controlsTheme doesn't save the choice; save it yourself in onToggle, or use your theme library as described above.
Unknown registry "@venusui"
Your shadcn CLI couldn’t find the namespace in the shadcn registry index. Use the latest CLI (npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.
No components.json found
Run npx shadcn@latest init in your project first.
Loading preview

Copies text to the clipboard and confirms with a check mark and a screen reader message.

Loading preview

A heart toggle that pops and bursts when liked, with an optional count.

Loading preview

Cards arranged in a ring that turns in 3D, with buttons, arrow keys and announcements.