Dynamically collapse Sidebar
- [X] I have searched the Issues to see if this bug has already been reported
- [ ] I have tested the latest version
Summary
The Sidebar component should have the ability to be collapsed and opened by the user clicking a button on it. Currently there's no way to accomplish this because the icon prop on Sidebar.Item expects a component, not an instance of a component, so there's no way to attach an onClick handler to it to then set the collapse property on the Sidebar.
Context
I need a sidebar or drawer on the right side of my page that the user can collapse and open as they want to so that it isn't always taking up space. For now I might have to just leave it open all the time because I have no good place to put a button that collapses and shows the sidebar.
We need to implement that classic renderIcon feature.
Hi all, just wonder if there is any possible workaround to acheive this toggling of sidebar ?
You need to target the <Sidebar.Collapse> <ul> in the DOM, like so https://github.com/themesberg/flowbite-react/blob/main/src/components/Sidebar/SidebarCollapse.tsx#L107 All we do is set it to hidden if you click <Sidebar.Toggle/>.
@juicemia @SamalaSumanth0262 Sidebar.Collapse has open property.