a primitive for creating a SpinButton component.
createSpinbutton<T extends string | number>(args: SpinButtonArguments<T>): AriaSpinButton<T>;
Array<T extends string | number>
string[]
number
JSX.HTMLAttributes<HTMLButtonElement>
JSX.HTMLAttributes<HTMLInputElement>
{ value: T }
import { createSpinbutton } from "solid-apg/spinbutton"; import type { VoidComponent } from "solid-js"; export const SpinButton: VoidComponent = () => { const { props, incrementButtonProps, decrementButtonProps, state } = createSpinbutton({ values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], mapping: [ "monday", "tuesday", "wednesday", "thursday", "rockstar", "every", "day", "friday", "saturday", "sunday" ], step: 5 }); return ( <div class="flex flex-col gap-2"> <button class="bg-green-600 hover:bg-green-700 active:bg-green-800 transition-colors p-4" {...incrementButtonProps} > <span class="font-bold">+</span> <span class="sr-only">Increment</span> </button> <input class="p-4" type="text" {...props} value={state.value} /> <button class="bg-red-600 hover:bg-red-700 active:bg-red-800 transition-colors p-4" {...decrementButtonProps} > <span class="font-bold">-</span> <span class="sr-only">Decrement</span> </button> </div> );};