Fixed menu inside a Sidebar pushable?
See original GitHub issueI’ve been stuck here. Basically, I added a fixed menu inside a sidebar pushable like so:
Sidebar.js
<Sidebar.Pushable as={ Segment }>
<Sidebar as={ Menu } animation="overlay" width='thin'
visible={ app.sidebarVisibility } icon='labeled'
vertical inverted>
<Menu.Item onClick={ () => ( app.sidebarVisibility && onToggleSidebar() ) }
as={ NavLink } exact to="/">
Home
</Menu.Item>
<Menu.Item onClick={ () => ( app.sidebarVisibility && onToggleSidebar() ) }
as={ NavLink } to="/menu">
Menu
</Menu.Item>
</Sidebar>
<Sidebar.Pusher onClick={ () => ( app.sidebarVisibility && onToggleSidebar() ) }>
<Container className="Main-container">
<Segment basic>
<NavBar app={ app } onToggleSidebar={ onToggleSidebar } />
{ children }
</Segment>
</Container>
</Sidebar.Pusher>
</Sidebar.Pushable>
NavBar.js
<Menu borderless fixed="top">
{ app.device && app.device.type === 'mobile' &&
<Menu.Item>
<Button basic icon="sidebar"
onClick={ () => ( !app.sidebarVisibility && onToggleSidebar() ) } />
</Menu.Item>
}
<Menu.Item header>Krispy Kreme</Menu.Item>
{ app.device && app.device.type !== 'mobile' &&
<Menu.Menu>
<Menu.Item as={ NavLink } to="/" exact>Home</Menu.Item>
<Menu.Item as={ NavLink } to="/menu">Menu</Menu.Item>
</Menu.Menu>
}
<Menu.Menu position="right">
<Menu.Item>
<Button basic icon="cart" label={ <Label color="red"> { cartItems } </Label> } />
</Menu.Item>
</Menu.Menu>
</Menu>
EDIT:
I was able to fix it by using flex layouts.
Basically, I had to make the Segment
component inside the Sidebar.Pusher
use display: flex
with flex-direction: column
so I can lay the contents properly. Then I gave it two children, the NavBar
and the Content
. I gave Content
a flex-grow: 1
property. Now The header stays on top. Here’s how it looks like now:
<Sidebar.Pusher onClick={ () => ( app.sidebarVisibility && onToggleSidebar() ) }>
<Segment basic>
<NavBar app={ app } onToggleSidebar={ onToggleSidebar } />
<Content>
{ children }
</Content>
</Segment>
</Sidebar.Pusher>
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Create reveal push menu with fixed position sidebar
First, when we mouseover the reveal menu, it instantly toggles between the states, revealing the menu (in a smooth animation, thanks to css- ......
Read more >How To Create a Side Navigation Menu - W3Schools
Add all page content inside this div if you want the side nav to push page ... Set the width of the side...
Read more >How to use the semantic-ui-react.Sidebar.Pushable function in ...
To help you get started, we've selected a few semantic-ui-react.Sidebar.Pushable examples, based on popular ways it is used in public projects.
Read more >Sidebar + Fixed Top Menu in Semantic-UI React-Reactjs
Sidebar & pusher --> <Sidebar.Pushable as={Segment}> <!-- Sidebar menu --> <Sidebar visible={this.state.visible} as={Menu} animation="push" width="thin" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@RhanCandia I am having the same issue but your solution isn’t working for me. Any chance you could post the full code, including css? Thanks!
I was unable to use this solution too.