Design SystemComponents
Buttons
Button component patterns and variants
Button Component
All button styling follows the HRMSElegance design system.
Button Variants
Default (Primary)
<Button variant="default">
Primary Action
</Button>
// Classes
className="bg-primary text-primary-foreground shadow-lg shadow-primary/25
hover:shadow-primary/35 hover:scale-[1.02]
active:scale-95 transition-all"Secondary
<Button variant="secondary">
Secondary Action
</Button>
// Classes
className="bg-secondary text-secondary-foreground"Destructive
<Button variant="destructive">
Delete
</Button>
// Classes
className="bg-destructive text-destructive-foreground"Outline
<Button variant="outline">
Cancel
</Button>
// Classes
className="border border-input bg-background hover:bg-accent hover:text-accent-foreground"Ghost
<Button variant="ghost">
Subtle Action
</Button>
// Classes
className="hover:bg-accent hover:text-accent-foreground"Link
<Button variant="link">
Learn More
</Button>
// Classes
className="text-primary underline-offset-4 hover:underline"Button Sizes
| Size | Class | Height | Usage |
|---|---|---|---|
| Default | size="default" | h-9 | Standard buttons |
| Small | size="sm" | h-8 | Compact UI |
| Large | size="lg" | h-10 | Primary CTAs |
| Icon | size="icon" | h-9 w-9 | Icon-only buttons |
Pill Buttons (Rounded Full)
For primary actions, use pill-shaped buttons:
<Button className="rounded-full shadow-lg shadow-primary/25">
Create Employee
</Button>Button with Icon
<Button>
<Plus className="w-4 h-4 mr-2" />
Add Employee
</Button>Icon-Only Button
<Button variant="ghost" size="icon">
<Settings className="w-5 h-5" />
</Button>AI Floating Button
The AI assistant button uses a special gradient:
<motion.button
className="
fixed z-50
bottom-6 right-6 md:bottom-8 md:right-8
w-14 h-14 rounded-full
bg-gradient-to-br from-violet-500 via-purple-500 to-fuchsia-500
text-white
shadow-xl shadow-violet-500/30
hover:shadow-2xl hover:shadow-violet-500/40
hover:scale-105 active:scale-95
transition-all duration-200
flex items-center justify-center
"
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
<Sparkles className="w-6 h-6" />
</motion.button>AI Button Rules
| Property | Value |
|---|---|
| Gradient | from-violet-500 via-purple-500 to-fuchsia-500 |
| Shadow | shadow-xl shadow-violet-500/30 |
| Hover Shadow | shadow-2xl shadow-violet-500/40 |
| Hover Scale | scale-105 |
| Active Scale | scale-95 |
DO vs DON'T
DO
// Correct: Primary button with shadow and scale effects
<Button className="shadow-lg shadow-primary/25 hover:scale-[1.02] active:scale-95">
Save Changes
</Button>DON'T
// Wrong: Plain button without effects
<button className="bg-blue-500 text-white px-4 py-2 rounded">
Save Changes
</button>Button Component Code
Full CVA-based implementation:
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow-lg shadow-primary/25 hover:shadow-primary/35 hover:scale-[1.02] active:scale-95",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline:
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-lg px-8",
icon: "h-9 w-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
);
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
}
);
Button.displayName = "Button";
export { Button, buttonVariants };