ResourceMenuItem

Sidebar entry that links to a resource's list view. Resolves the label, icon and route from the resource definition declared in <Admin>.

Installation

pnpm dlx shadcn@latest add @shadmin/resource-menu-item

Usage

<ResourceMenuItem> is used by <Menu> to render one entry per registered resource. You can also use it directly when building a custom sidebar:

import { ResourceMenuItem } from "@/components/admin";
 
const CustomMenu = () => (
  <nav>
    <ResourceMenuItem name="posts" />
    <ResourceMenuItem name="comments" />
  </nav>
);

The component returns null when the user does not have list access (checked through useCanAccess). While the permission check is pending it renders a <Skeleton> placeholder.

Props

PropRequiredTypeDefaultDescription
nameRequiredstringResource name registered via <Resource name="…">
classNameOptionalstringExtra Tailwind classes appended to the menu button
onClickOptional() => voidInvoked after navigation; the default sidebar uses it to close the mobile drawer

name

The name prop must match a resource registered in <Admin>. The component reads the resource definition for the icon, label, and list path. If no resource by that name exists, <ResourceMenuItem> renders nothing.