Cloff Labs

Interactive Button

Multipurpose stateful Interactive button

Installation

Run the following command

npx shadcn@latest add https://ui.cloffstudio.com/r/interactive-button.json

Props

PropsTypeDefaultDescription
childrenReact.ReactNodeEnterButton lable show in the idle state.
classNamestringundefinedAdditional CSS classes applied to the button wrapper.
onClick(event: MouseEvent<HTMLButtonElement>) => void | Promise<void>undefinedClick handler (can be async). If it throws/rejects the button goes to failure
loadingTextstringLoading...Text shown while in loading state.
loadingTextstringLoading...Text shown while in loading state.
successTextstringSucess!Text shown when action succeeds.
failureTextstringFailed!!Text shown when action failed.
loadingDurationnumber (ms)1500Delay (ms) after starting loading before switching to success (applied after onClick resolves).
resetDelaynumber (ms)3000Time (ms) the button stays in success or failure before returning to idle.
enableEnterKeybooleanfalseIf true, pressing Enter triggers the button when state is idle
type"button" | "submit" | "reset"buttonNative button type attribute.
formstringundefinedForwarded form attribute (form id).
namestringundefinedForwarded name attribute.
valuestringundefinedForwarded value attribute.