Files
IdeaSDK/frontend/src/shared/ui/IconButton.tsx
Blomios 307ae71857 feat: add main features
Agents for developpement added + frontend add + backend added. Git viewer created + agent and template creator + layout and project creator
2026-06-06 01:27:01 +02:00

43 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** IconButton — a square, icon-only button (close ×, toolbar actions) (LD). */
import { forwardRef } from "react";
import { cn } from "../lib/cn";
export type IconButtonSize = "sm" | "md";
export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
/** Required accessible name (icon-only buttons have no text). */
"aria-label": string;
/** Control size. Defaults to `md`. */
size?: IconButtonSize;
}
const SIZES: Record<IconButtonSize, string> = {
sm: "h-6 w-6 text-xs",
md: "h-8 w-8 text-sm",
};
/** A compact, icon-only button styled as a ghost control. */
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(
{ size = "md", className, children, ...rest },
ref,
) {
return (
<button
ref={ref}
type={rest.type ?? "button"}
className={cn(
"inline-flex items-center justify-center rounded-md text-muted transition-colors",
"hover:bg-raised hover:text-content focus-visible:outline-none",
"disabled:opacity-50 disabled:cursor-not-allowed",
SIZES[size],
className,
)}
{...rest}
>
{children}
</button>
);
});