Interaction JS behaviour

Pull cord

A real rope — verlet physics, gravity, wobble — hanging from the top edge of any box: grab it, pull it down until it lights up, let go — it springs home and settles. For the lamp switch, a theme toggle, any playful on/off.

Real scenarios

The component as it is used in a product — not a specimen grid.

The reading lamp

A rope with real physics in a dashed box — grab the knob, pull it down until it glows, and let go. The lamp answers; the cord springs home and wobbles to a stop.

Off

Pull to flip the theme

The cord is just a trigger: here a release calls $nxTheme.toggle() on the whole page. Pull this one and watch the playground switch sides.

Light

Important props

Important props
Prop Type Default What it does
label string __('nabuxui::ui.pullCord') Accessible name of the knob.
trigger number 72 How many px of pull arm it; releasing below this does nothing.
segments number 12 Simulated rope segments; more bends softer and costs more.
tone string 'accent' accent · gold · violet · success — the armed knob’s glow.
height string null The box’s block size; the rope fills it.
action string null A Livewire method called on release; the nx-cord-pull event always fires too.

Snippet

<div x-data="{ lit: false }" x-on:nx-cord-pull="lit = ! lit">
    <x-nx::pull-cord label="چراغ مطالعه" tone="gold" height="14rem" />
    <div x-bind:class="lit && 'nx-beam'" data-tone="gold">…لامپ…</div>
</div>

{{-- or straight to Livewire --}}
<x-nx::pull-cord action="lightSwitch" tone="violet" height="12rem" />