Dice UI

Pending

Component 1

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";

export default function PendingLinkDemo() {
  const [isPending, setIsPending] = React.useState(false);

  const onNavigate = React.useCallback(
    (event: React.MouseEvent<HTMLAnchorElement>) => {
      event.preventDefault();
      setIsPending(true);

      // Simulate async navigation
      setTimeout(() => {
        setIsPending(false);
      }, 2000);
    },
    [],
  );

  return (
    <div className="flex items-center justify-center">
      <Pending isPending={isPending}>
        <a
          href="/docs/components/pending"
          onClick={onNavigate}
          className="text-primary underline-offset-4 hover:underline"
        >
          {isPending ? "Loading dashboard..." : "Go to Dashboard"}
        </a>
      </Pending>
    </div>
  );
}

Dependencies

More by Dice UI

View all
  • Compare Slider

    Compare Slider

    75
  • Sortable

    Sortable

    49
  • Circular Progress

    Circular Progress

    41
  • Status

    Status

    28
  • Banner

    Banner

    19
  • Stack

    Stack

    8
  • Scroller

    Scroller

    5
  • Kanban Board

    Kanban Board

    4

Explore more

Part of Dice UI — browse the full library on 21st.dev.