Making full-size main content with semantic-UI Sidebar react components
Asked Answered
A

3

9

I'm trying to make a Webapp with react using Semantic Ui components. However, I'm really struggling to make the main content component take up the full-size of the screen (see image). I want the main content component to fill up the rest of the space but it seems like it's only taking up as much space as it needs to. Ultimately I want to be able to have the sidebar sticky and only scroll the main content

render() {
const { visible } = this.state
return (
  <div>
    <Button onClick={this.toggleVisibility}>Toggle Visibility</Button>
    <Sidebar.Pushable as={Segment}>
      <Sidebar as={Menu} animation='push' width='thin' visible={visible} icon='labeled' vertical inverted>
        <Menu.Item name='home'>
          <Icon name='home' />
          Home
        </Menu.Item>
        <Menu.Item name='gamepad'>
          <Icon name='gamepad' />
          Games
        </Menu.Item>
        <Menu.Item name='camera'>
          <Icon name='camera' />
          Channels
        </Menu.Item>
      </Sidebar>
      <Sidebar.Pusher>
        <Segment basic>
          <Header as='h3'>Application Content</Header>
          <Image src='/assets/images/wireframe/paragraph.png' />
        </Segment>
      </Sidebar.Pusher>
    </Sidebar.Pushable>
  </div>
)
}

I've tried to apply the style inline {height:100%} to everything from within the up the hierarchy to the root component but nothing seems to make it fill the rest of the page. I know that this seems like such a simple problem, but I'm stuck haha. Any ideas?

Cheers desired outcome

Arrange answered 26/6, 2017 at 13:3 Comment(0)
Q
11

The sidebar will take the same height as its enclosing div. It looks like you want the content to stretch to exactly 100% of the viewport. If this is the case, you can set height on the enclosing div to '100vh'.

<div style={{height: '100vh'}} />

If you want the height to possibly go beyond, you can set min-height to '100vh'.

<div style={{minHeight: '100vh'}} />

If you want it to just take up the rest of the page before or after some other content, you can do the following:

<div style={{minHeight: '100vh', display: 'flex', flexFlow: 'column nowrap'}}>
    <div>Content Before</div>
    <div style={{flex: 1}}>
        Main Content with Sidebar
    </div>
    <div>Content After</div>
</div>
Quant answered 28/9, 2017 at 3:11 Comment(0)
A
1

I know I'm late but this will sure help others.

you can actually override the default css style of pusher for example:

.pushable:not(body) {
  -webkit-transform: none;
  -ms-transform: none;
      transform: none;
}

.pushable:not(body) > .ui.sidebar,
.pushable:not(body) > .fixed,
.pushable:not(body) > .pusher:after {
  position: fixed;
}
Acie answered 7/8, 2020 at 4:24 Comment(1)
this has solved my problemCitizenship
W
0

Add new class for segment basic with height 100vh

Wilmoth answered 20/3, 2020 at 19:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.