The SidebarLinks component is used to render a list of navigation links within a sidebar, specifically optimized for RTL (Right-to-Left) layouts. It accepts a routes prop, which is an array of route objects.
Each route object in the array must follow this structure:
layout: A string representing the base layout path (e.g., '/admin', '/auth', or '/rtl'). The component only renders links where the layout matches one of these three values.path: The specific path segment for the route.name: The display name for the link.icon: (Optional) A React component to be used as the link icon. If omitted, it defaults to DashIcon.
The component automatically detects the active route using react-router-dom's useLocation and applies active styling (bold text and a colored indicator bar) to the matching link.
import { SidebarLinks } from "components/sidebar/componentsrtl/Links";
const myRoutes = [
{
layout: "/rtl",
path: "dashboard",
name: "Dashboard",
icon: <MyCustomIcon />
},
{
layout: "/rtl",
path: "profile",
name: "Profile"
// icon defaults to DashIcon if not provided
}
];
function MySidebar() {
return <SidebarLinks routes={myRoutes} />;
}