ActionsMenu

Composed dropdown menu for row and card actions.

Recipe Source

components/ui/actions-menu.tsx
"use client";import { Button } from "@giddaa-housing/ui/button";import {	DropdownMenu,	DropdownMenuContent,	DropdownMenuItem,	DropdownMenuTrigger,} from "@giddaa-housing/ui/dropdown-menu";import { MoreHorizontalIcon, MoreVerticalIcon } from "lucide-react";import type * as React from "react";import { cn } from "./lib/cn";type ActionsMenuProps = React.ComponentProps<typeof DropdownMenu>;type ActionsMenuTriggerProps = React.ComponentProps<	typeof DropdownMenuTrigger> & {	"aria-label"?: string;	children?: React.ReactNode;	orientation?: "horizontal" | "vertical";	size?: React.ComponentProps<typeof Button>["size"];	variant?: React.ComponentProps<typeof Button>["variant"];};type ActionsMenuContentProps = React.ComponentProps<typeof DropdownMenuContent>;function ActionsMenu({ children, ...props }: ActionsMenuProps) {	return <DropdownMenu {...props}>{children}</DropdownMenu>;}function ActionsMenuTrigger({	"aria-label": ariaLabel = "Open row actions",	children,	className,	onClick,	orientation = "vertical",	size = "icon-sm",	variant = "ghost",	...props}: ActionsMenuTriggerProps) {	const Icon =		orientation === "horizontal" ? MoreHorizontalIcon : MoreVerticalIcon;	return (		<DropdownMenuTrigger			aria-label={ariaLabel}			render={<Button variant={variant} size={size} />}			className={className}			onClick={(event) => {				event.stopPropagation();				onClick?.(event);			}}			{...props}		>			{children ?? <Icon />}		</DropdownMenuTrigger>	);}function ActionsMenuContent({	align = "end",	className,	side = "bottom",	...props}: ActionsMenuContentProps) {	return (		<DropdownMenuContent			side={side}			align={align}			className={cn("min-w-48", className)}			{...props}		/>	);}function ActionsMenuItem({	onClick,	...props}: React.ComponentProps<typeof DropdownMenuItem>) {	return (		<DropdownMenuItem			onClick={(event) => {				event.stopPropagation();				onClick?.(event);			}}			{...props}		/>	);}export { ActionsMenu, ActionsMenuContent, ActionsMenuItem, ActionsMenuTrigger };

Usage

import { ActionsMenu, ActionsMenuContent, ActionsMenuItem, ActionsMenuTrigger } from "@/components/recipes/actions-menu";

<ActionsMenu><ActionsMenuTrigger /><ActionsMenuContent><ActionsMenuItem>View details</ActionsMenuItem></ActionsMenuContent></ActionsMenu>

Examples

Default Actions Menu

Use this for compact contextual actions in tables, cards, and list rows.

Props

Prop/APITypeDefaultDescription
orientation`"horizontal""vertical"`"vertical"
sizeButton size"icon-sm"Controls trigger density.
variantButton variant"ghost"Controls trigger styling.
native/root propsReact component props-Passed through to the underlying dropdown parts.

Accessibility

  • Keep the default trigger aria-label or provide a more specific one.
  • Use destructive item variants for irreversible actions.
  • Keep menu actions short and imperative.

On this page