Skip to content
Dinvolt
Esc
↑↓navigate↵open⌘Jpreview
On this page

Action components

For Admin panel only projects, the login is /, the home page is /dashboard, and other panel pages omit the /admin prefix. Components use @/components and @/components/ui. API endpoints such as /api/admin/users/export keep their paths. Examples below use the combined public website + admin panel layout; generated standalone guides use the app’s actual paths.

Action components

Use these buttons for pending actions, clipboard copying and inline deletion confirmation.

Install the public block first:

npx dinvolt ui add @dinvolt/public-actions --target public
bunx dinvolt ui add @dinvolt/public-actions --target public
pnpm dlx dinvolt ui add @dinvolt/public-actions --target public
yarn dlx dinvolt ui add @dinvolt/public-actions --target public

Projects with an admin panel already include these components. The imports below work in public-only and admin-only projects. For the admin area of a combined project, replace @/components/ui/ with @/components/admin/ui/.

Show a pending form action

ActionButton disables itself while pending and swaps its label without resizing the button.

Create a submit button for a React form action:

"use client";

import { useFormStatus } from "react-dom";

import { ActionButton } from "@/components/ui/action-button";

export function SaveButton() {
  const { pending } = useFormStatus();

  return (
    <ActionButton type="submit" pending={pending} pendingLabel="Saving…">
      Save changes
    </ActionButton>
  );
}

Render SaveButton inside a form that uses React’s action prop. The form owns validation, saving and error feedback.

For other operations, pass your request’s pending state directly. Required props are a string child label, pending and pendingLabel; icon is optional.

ActionButtonContent is exported from the same module when you need this presentation inside an existing control, such as a menu item.

Copy text

CopyButton writes value to the clipboard. The displayed label can differ from the copied value:

"use client";

import { CopyButton } from "@/components/ui/copy-button";

export function CopyEmail() {
  return (
    <CopyButton value="hello@example.com" aria-label="Copy email address">
      hello@example.com
    </CopyButton>
  );
}

Omit children to display value automatically. Use inline to fit the button into a line of text.

A successful copy shows a check for two seconds. A failed copy shows retry feedback. Button variants and sizes are supported; provide an accessible label for icon-only controls.

Confirm a deletion

DeleteButton asks for confirmation on the first activation and calls onDelete on the second. Escape, an outside click or moving focus away cancels confirmation.

Connect it to your deletion operation:

"use client";

import { DeleteButton } from "@/components/ui/delete-button";

type DeleteRecordButtonProps = {
  pending: boolean;
  onDelete: () => void;
};

export function DeleteRecordButton({
  pending,
  onDelete,
}: DeleteRecordButtonProps) {
  return (
    <DeleteButton
      pending={pending}
      onDelete={onDelete}
      confirmLabel="Delete this record?"
    >
      Delete record
    </DeleteButton>
  );
}

Pass the mutation’s pending state to prevent repeat activation. Your operation owns authorization, deletion, error feedback and data refresh.

Customize the labels, icon, size or variant as needed. Both action and delete buttons respect reduced motion.

Was this page helpful?