Shadix UIAction Button
A customizable action button component for shadcn/ui. Built with async function handling, and interactive loading states.
A customizable action button component for shadcn/ui. Built with async function handling, and interactive loading states.
"use client";
import type React from "react";
import ActionButton from "@/components/action-button";
const ActionButtonDemo: React.FC<ActionButtonDemoProps> = () => {
const onConfirm = async () => {
try {
return await new Promise<{ message?: string; error?: boolean }>(
(resolve, reject) => {
const actions = ["reject", "resolve"];
const action =
actions[Math.floor(Math.random() * actions.length)];
setTimeout(
() =>
action === "resolve"
? resolve({
message: "Action successful",
error: false,
})
: reject({
message: "Something went wrong",
error: true,
}),
1000,
);
},
);
} catch (error: unknown) {
return {
message: (error as Error).message ?? "Something went wrong",
error: true,
};
}
};
return (
<ActionButton
variant="outline"
popupContent={
<div>
This action cannot be undone. This will permanently delete
your data from our database.
</div>
}
title="Are you sure want to continue?"
onConfirm={onConfirm}
>
Click Me
</ActionButton>
);
};
type ActionButtonDemoProps = Record<string, never>;
export default ActionButtonDemo;
import ActionButton from '@/registry/new-york/components/action-button/action-button';
const ActionButtonDemo = () => {
return (
<ActionButton onConfirm={() => {}} popupContent={<div>This is a popup</div>}>
Click Me
</ActionButton>
);
};import ActionButton from '@/components/ui/action-button';
const ActionButtonDemo = () => {
return (
<ActionButton variant="outline" onConfirm={() => {}} popupContent={<div>This is a popup</div>}>
Click Me
</ActionButton>
);
};import ActionButton from '@/components/ui/action-button';
const ActionButtonDemo = () => {
return (
<ActionButton onConfirm={() => {}} popupContent={<div>This is a popup</div>} disabled>
Click Me
</ActionButton>
);
};Built by Gihan (apix-js) for Shadcn at Vercel. Source code on GitHub.
Prop
Type