absent-sapphire•2mo ago
how do I change order of sidebar menu items
I've recreated a sidebar with the help of useMenu, but I have no idea what dictates the order of the menu items. It appears to be almost random.
7 Replies
Hi @JuicyBenjamin. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The order of sidebar menu items in Refine is determined by the order of the resources array you provide to the <Refine> component. The useMenu hook generates menu items based on this array, so the sequence in which you define your resources will be reflected in the sidebar menu order.
For example:
In this case, the sidebar will show "posts" first, then "users", then "categories"—matching the order in the array. If you want to change the order, simply rearrange the resources in the array.
If you are using multi-level menus (with meta.parent), the order within each group is also determined by the order in the resources array. There is no mention in the documentation of a separate property (like "order" or "priority") to control menu order; it is strictly the array order that matters Multi Level Menu useMenu Usage.
If your menu appears "almost random," double-check the order of your resources array. Also, ensure that you are not dynamically modifying the resources array or using logic that could affect its order at runtime.
If you need more advanced ordering (such as grouping or custom sorting), you can manipulate the menuItems array returned by useMenu in your custom sidebar component before rendering it. However, by default, the order is controlled by the resources array.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@167296048367140864> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
absent-sapphireOP•2mo ago
@kapa.ai I can tell you as much as that isn't the case. The order in the sidebar is different to the order of the resources
Let me check the knowledge base for you again. One moment! :books:
----------------------
Thank you for your feedback. According to the official Refine documentation, the order of sidebar menu items generated by useMenu should follow the order of the resources array provided to the <Refine> component. However, if you are experiencing a different order in your sidebar, the documentation does not provide an explicit explanation for this discrepancy or describe any built-in property (such as order or priority) to control menu item order beyond the array sequence useMenu documentation.
If you are using multi-level menus (with meta.parent), the order within each group should also follow the order in the resources array Multi Level Menu. There is no mention in the knowledge sources of any other mechanism that would alter the order.
If your sidebar order does not match the resources array, the knowledge sources do not provide enough information to explain or resolve this behavior. You may want to check for any custom logic in your sidebar component or any dynamic changes to the resources array at runtime. If none exist, this could be an undocumented behavior or a bug.
I'm sorry, but the knowledge sources do not contain enough information to definitively answer why the order is different in your case.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@167296048367140864> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
unwilling-turquoise•2mo ago
At least for me, and based on what I see in source code the AI answer sounds correct
rival-black•2mo ago
Thanks