RA Tree Menu
React admin is an awesome tool for creating admin panels easily. If you checked out RA Demo you may see tree like menus. But this menu isn't included in react-admin
package.
This is unofficial react-admin
plugin package which adds support for Tree Menu in RA apps.
Installation
Install using npm
.
npm install --save ra-tree-menu
Basic usage
Here is the example code to use ra-tree-menu
on your RA app.
// ./App.js;;; const App = <Admin appLayout=TreeMenuLayout> <Resource name="users" /> <Resource name="user_posts" /> <Resource name="user_images" /> <Resource name="groups" /> <Resource name="group_members" /> </Admin>;
The menu structure will be like this:
- Users
- Users
- User posts
- User images
- Groups
- Groups
- Group members
Customization
Custom layout
If you want to use your custom appLayout
, you can use TreeMenu
component.
// ./CustomLayout.js;;; <Layout ...props menu=TreeMenu />;
// ./App.js; const App = <Admin appLayout=CustomLayout> ... </Admin>;
Need to change menu structure?
No problem. You need to import tree menu component and extend it with your custom structure generator. Here's how:
; { const resources = thisprops; const resByName = ; var structure = ; return structure; }
Check out full example: ./examples/custom_structure.js
Then use exported object to create your custom layout and set it to <Admin />
object as appLayout
property.
Contributors
Misir Jafarov: https://misir.xyz
React Admin: https://github.com/marmelab/react-admin