About
A utility component and hook that applies pending/loading state to any interactive element, blocking clicks and keyboard activation with proper ARIA attributes.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Pending to your project and fits it to your theme.
Code
How Pending is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import { Pending } from "@/components/ui/pending";
import * as React from "react";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
export default function PendingSwitchDemo() {
const [isEnabled, setIsEnabled] = React.useState(false);
const [isPending, setIsPending] = React.useState(false);
const onToggle = React.useCallback(() => {
setIsPending(true);
// Simulate async API call to save setting
setTimeout(() => {
setIsEnabled((prev) => !prev);
setIsPending(false);
}, 1500);
}, []);
return (
<div className="flex flex-col gap-6">
<div className="flex items-center justify-between">
<div className="flex flex-col gap-1">
<Label htmlFor="notifications">Email Notifications</Label>
<p className="text-muted-foreground text-sm">
{isPending
? "Saving..."
: "Receive email about your account activity"}
</p>
</div>
<Pending isPending={isPending}>
<Switch
id="notifications"
checked={isEnabled}
onCheckedChange={onToggle}
className="data-pending:cursor-wait data-pending:opacity-70"
/>
</Pending>
</div>
<div className="flex items-center justify-between">
<div className="flex flex-col gap-1">
<Label htmlFor="marketing">Marketing Updates</Label>
<p className="text-muted-foreground text-sm">
Get tips, updates, and special offers
</p>
</div>
<Switch id="marketing" />
</div>
</div>
);
}








