Semantic-ui: [Menu] Make Fixed Menu Collapsable

Created on 4 Oct 2013  ·  146Comments  ·  Source: Semantic-Org/Semantic-UI

Hi,

Having a collapsable fixed menu is something of a must have with the rise of phones. Something similar to Bootstrap's collapsable navbar or Foundation's top-bar would be great.
http://getbootstrap.com/components/#navbar
http://foundation.zurb.com/docs/components/top-bar.html#

Enhancement

Most helpful comment

@jlukic Isn't stuff like this kind of the point in using a framework? :confused:

For me this seems to be a strange response in light of my remark... would you be willing to let us know the reasoning here? :smile:

Just use a separate menu for mobile and show it using media queries.

All 146 comments

I agree that all menus should reformat to vertical menus when at mobile widths. With fixed menus converting to collapsible, click-to-open menus. The issue with click-to-open menus though is they require javascript.

Which means there would need to be a behavioral extension to menu to handle this.

Trying out semantic for the first time and looking for this too. Spoiled by bootstrap :-).

Any updates on this?
I read in another issue "Menus will have responsive variations". Any definite release date?

Seeing the amount of activity on this, I'll prioritize this for this or next week.

+1

+1. This will be super useful.

+1 This is a must.

Hey @jlukic, If you need any help implementing this, I would be happy to take a shot at it. Just let me know if you had any plans/ideas for how you wanted it to be implemented...

+1 :)

Seems like with 1.0, "right menu" does not work with mobile. Instead of collapsing (a-la bootstrap) it wraps around.

Was this resolved and I'm missing something? if so, is there an example?

Anyone figured a workaround to do this "manually"?

Has this been done??

It has not been done yet.

+1

+1 must have

Is there a time frame when this might possibly be implemented?

I would say after #1571 which is my main focus right now.

+1

I'm using the sidebar component in the meantime, but this is definitely a staple now.

+1

+1

:+1:

+1 Would also love to help in the implementation if needed.

+1

+1

+1

+1

+1

+1

really beautiful css framework !
much appreciate your work , thank you!

  • 1 for this :)

This is something I would love to see as well. Do not want to load a separate menu just for this.

+1 framework good like this one deserves it

+1 I notice that when you use stackable menus in 2.0 with the tab feature on mobile the menu just makes the tabs not viewable making the whole site non mobile friendly.

+1

+1 for stackable collapse menu

+1 for me too.

+1

+1

Sad to be one more to add a +1 here, with the issue having almost hit its second aniversary. This seems such a mandatory feature for nowadays mobile needs. I tried to implement something similar using mobile only/computer only classes but they only work for rows/columns, and messed a lot with the menu classes. Please, take a look at this! :(

I use bootstrap navbar unfortunately

Isn't it too much overhead to use both frameworks? Or did you manage to
extract only the navbar from bootstrap?
On 18 Sep 2015 05:18, "Mahdi Majidzadeh" [email protected] wrote:

I use bootstrap navbar unfortunately


Reply to this email directly or view it on GitHub
https://github.com/Semantic-Org/Semantic-UI/issues/157#issuecomment-141378624
.

At the core of this issue in my mind is - what is the architecture decision in Semantic to handle this using either - mostly responsive solution or event / JavaScript to handle it? I need to pour over docs to see if I can determine, identify that...

This is one example of something needed, there are plenty more like this - but, they all should follow the same core tenets of the Semantic UI way...

And should this be more of how you form a "recipe" to use many Semantic elements combined to form a more strict component like this?

yes, only bootstrap nabvar

On Fri, Sep 18, 2015 at 7:04 PM, Igor Santos [email protected]
wrote:

Isn't it too much overhead to use both frameworks? Or did you manage to
extract only the navbar from bootstrap?
On 18 Sep 2015 05:18, "Mahdi Majidzadeh" [email protected] wrote:

I use bootstrap navbar unfortunately


Reply to this email directly or view it on GitHub
<
https://github.com/Semantic-Org/Semantic-UI/issues/157#issuecomment-141378624

.


Reply to this email directly or view it on GitHub
https://github.com/Semantic-Org/Semantic-UI/issues/157#issuecomment-141470412
.

+1

+1 for all +1s

+1

+1

+1

+1

+1

+1

+1

This is crucial deciding factor to use between semantic and bootstrap. +1 for this feature and hopefully it will get added to the framework.

Not relating to collapsing, but the "right menu" comment from @raniglas:

Inserting an empty "right menu" div prior to menu items I wanted to have on the right, ended up with a reasonable mobile stacked menu. Open to any suggestions on alternatives.

<div class="ui stackable menu">
  <a class="item">Left Item 1</a>
  <a class="item">Left Item 2</a>
  <div class="right menu">
  </div>
  <a class="item">Right Item 1</a>
  <a class="item">Right Item 2</a>
</div>

Hi, I found an implementation of this feature here http://codepen.io/anon/pen/zrBBoa
It will be awesome if you incorpore that in the sources.

+1, hacking my own collapsible menu makes Semantic-UI a much less attractive option. I like Semantic's styling more than Bootstrap, but that collapsible menu is a crucial piece of any responsive, mobile-ready UI framework.

Any news according to this feature?
I still run semantic ui 1.x, waiting just for this for upgrading the libs. The menu in 1.x is much more responsive than the one in 2.x.

+1

agreed, but you can not expand and collapse the drop-downs in that solution when in mobile view.

I'm very surprised that after more than 2 years, this still isn't implemented... +1 for this issue.

+1

+1

+1. Collapsable menu is a kinda must.

+1

+1

successfully migrated back to bootstrap, collapsible menu works very well there. thanks for the good time with semanic ui! will watch this issue to be informed when it will be done. hopefully it will not hit its 3rd anniversary. best regards.

:wink:

+1

+1

+1

+1

+1

+1

The amount of vitriol i've received about this particular issue...

Well it is the second most commented open issue on the repo, and the first one at least has a piece of quality code which just needs to get merged to master... I think we'd all reeeeally like to see this get built, or at least understand if there's something particularly difficult about implementing it.

@jlukic Have you considered using a checkbox to work around the javascript requirement? The checkbox could hold the opened/closed state and toggle CSS classes (example). I don't know if you're still against using javascript for the collapsible functionality (as per the original response to the issue).

There is a pure javascript solution(?) floating around in the internet, but I'm not sure this is the right way to go, has anyone else worked this out?

Btw, thanks to the devs for the awesome work! Consider all the guys asking for this feature as people who don't want to use other frameworks!

+1

I think an external plugin for a collapsible menu should be made available. Semantic UI beats Bootstrap for me - I was just about to redesign my whole site - but the lack of the menu has made me reconsider :(

Just use a separate menu for mobile and show it using media queries.

+1

+1

Check #1114

+1

+1

+1

@jlukic Isn't stuff like this kind of the point in using a framework? :confused:

For me this seems to be a strange response in light of my remark... would you be willing to let us know the reasoning here? :smile:

Just use a separate menu for mobile and show it using media queries.

+1

+1

+1

+1

Just use a separate menu for mobile and show it using media queries.

why can't you build this in like columns? where we can do for example
sixteen wide tablet twelve wide computer column

I want to show fixed menus on both mobile and desktop but when showing on mobile it cuts off any menu items which are too wide, I simply want the text labels to disappear on mobile so only the icons show, this way I can at least show 5-6 items...

:+1: +1

It's been more than 3 years and because of this task Semantic.ui seems the worst framework to work with.

That's an exaggeration. A workaround exists. Use a separate menu for mobile and show it using media queries. It's shitty but to call Semantic the worst framework to work with because of this one thing is ridiculous.

It's possible to achieve but i'm more interested in getting the collapse/expand from this mobile version menu to animate instead of appear, similar to 'ui sidebar's bottom push'.
Any idea how to achieve this?

UI Framework with 27k stars that doesn't support a basic collapsable menu is okay, but my response is an exaggeration.

Funny world.

I want my money back, too!

Or in other words: seems this is not so important to anyone in order to actually implement it, otherwise it would have been done. If it's to you, why not do it?

Can this be achieved using an accordion and triggering it from the menu icon?
I cannot seem to get it working but maybe someone can give it a try. :-)

been 3 years...

It's really strange that Semantic UI don't offers a simple responsive menu.

http://ehkoo.github.io/semantic-ui-examples/navbar/ - here is an example of collapsable navigation bar, but it requires rendering menu items twice.

@ivantcholakov , All responsive design philosophy is do every thing once!!

+1

http://chineque.com.br/labs/navbeer/ - another example, the menu is to be rendered only once.

Edit 20-OCT-2016: https://github.com/ezpabon/navbeer

After a week of trying out Semantic UI I am ditching it and going back to Bootstrap. This issue coupled with lack of always open sidebar that doesn't push content makes this a pretty painful framework to work with.

I'm sorry that you're leaving SUI. There is a collapsible menu but it is quite limited in scope. There is generally no way to support the full features of menu for mobile in a consistent way without a large amount of css code duplication.

I do think however the downsides to including separate html to render your mobile menu is negligible. Generally you'll want to organize the links in a different way, use different styles and remove items for mobile. The only downside to including it twice is 'lack of elegance' which I can understand how would upsetting for devs and a few more text over the wire.

Confused about this.
Can there at least be a solution and explanation in the docs?

Is there any good practice using semantic UI to make menu good on mobile phone?

+1

@tarvos21
http://iridadesign.com/starter-public-edition-4/www/ - see the blue top menu, extract the HTML using your browser. This is what I am capable to have for now.

Note: After copying the snippet, for non-customized Semantic UI replace the following:

<div class="mobile hidden row">

with

<div class="computer tablet only row">

@ivantcholakov
good solution, it seems to work, thanks for sharing!

Still waiting for this

+1

Please use GitHub reactions instead of just posting +1.

🥂

Just for those in need I have come up with a workaround, here is the code. It is simply a ui simple dropdown item that works on mobile and no JS required. I know it is not the same but this might help someone.

<div class="ui borderless fixed stackable main menu">
    <div class="ui text container">
        <a href="#" class="header item">
            <img class="logo">
            SITENAME
        </a>
        <div class="right menu">
        <div class="ui simple dropdown item">
        Menu
        <i class="dropdown icon"></i>
        <div class="menu">
            <a href="#" class="item">item</a>
        </div>
        </div>
        </div>
    </div>
</div>

Since this feature obviously isn't going to be implemented (it's been over three years), can you perhaps include an example in the docs (menu maybe?) explaining how to create a mobile-responsive navbar with media queries?

👍

Dumbledore: "After all these years?"
Snape: "Always"

+1

It's seriously sad that such a basic thing has been forgotten, really enjoyed working with Semantic while it lasted but i refuse to spend more time on making 2 menus (A sidebar and a menu) to have a working Responsive Navigation. Double the effort for something that should ease the process.

+1 (Will revisit S.UI if added in future RCs)

+1

Here is a solution that behaves like Bootstrap and does not require a second set of menu items. It requires just a tiny bit of JS and CSS.
The JS:

$(function() {
// Set up to handle wrapping of tab menu (tab actuator) items
    $(window).resize(function() {
      checkIfWrapped();
    });

    checkIfWrapped(); // Make sure the function is fired upon document ready
});

```javascript
// Detect whether a Semantic UI tabular menu is wrapped
function checkIfWrapped() {
var pos_top_1st = $('.tabular.menu .item').first().position().top;
$('.tabular.menu .item:not(first-child)').each(function() {
var pos_top = $(this).position().top;
if (pos_top > pos_top_1st) {
$(this).parent().addClass('wrapped');
return;
} else if (pos_top == pos_top_1st) {
$(this).parent().removeClass('wrapped');
}
});

The HTML structure.  (Note that placing the .tabular.menu .item-s  inside a div within the overall .tabular.menu allows the use of a separate .right.menu within the .tabular.menu if desired) :
```html
          <div id="tabs-menu" class="ui top attached tabular menu">
              <div id="qj-tabs">
                  <div class="tab item"></div>
                  <div class="tab item"></div>
                  <div class="tab item"></div>
              </div>
              <div class="right menu">
                  <a class="tab item"><i class="add icon"></i> Add Job</a>
                  <a class="tab item"><i class="copy icon"></i> Copy Item</a>
              </div>
          </div>
              <div class="botttom attached tab segment"></div>
              <div class="botttom attached tab segment"></div>
        </div>

The CSS:

#qj-tabs {
  display: flex !important;   /* Will not work unless defined as display: flex */
  flex-direction: row !important;
  flex-wrap: wrap !important;
}

#tabs-menu .wrapped .item {
  border-radius: 5px !important;
  border: 1px lightgray solid !important; /*  Just styling for the default theme here */
  margin: 0 2px 2px 0 !important;
}

#tabs-menu .wrapped .active.item {
    background-color: lightgray;
}

Thanks to Mr. Boris the answer here that got me started on this solution.

@jlukic
Would love to see a solution for this issue.

Thank you

Any working solution on this issue yet?

@andrewoko-odion Doesn't seem like there's much being done about this, it has been opened since 2013 and yet no solution right out of the box. Only shared code to try and imitate the behavior which i still refuse to make use of if i don't need to when something so simple and required this days should be already be implemented on the framework itself.

Absolutely agree with @DualPixel
+1

As much as I like Semantic, I gotta say that this is a deal breaker for me. As soon as this gets fixed, I'm all in.

+1

+1

@CanadianEngineer, @pierre-H You might want to look at the solution I posted on March 28th just above here. It's really easy to implement. I do agree that this needs to be implemented into the main library though.

Any working solution on this issue yet?

+1

Wow! I really don't understand why the core team of semantic ui don't want to consider a responsive menu. This should have been a great framework to compete well enough with Bootstrap but the lack of support for responsive menu is just so painful. @jlukic should see that this feature is one which everyone wants and then make it a priority, please!

@Pythonian totally agree! +1

Same for me, I really enjoy semantic ui but this function should be native since a long long time...

Waiting, please implement + 100000000

+1

+1

+1
I'm not as vehemently opposed as some to having two separate layouts for a menu (using React makes creating that not too much of a chore and maintains just a single source location). However, I'd agree that this should really be consider a necessity for a modern, full-featured suite of styling tools such as Semantic.

+1

After 4 years getting "+1" mails from this thread I'll mute this now. Anyway, bye!

SUI newbie here:
Really, guys, if you don't want to complicate something in your code because of adding responsive menu, so just write and add some right example of responsive menu with semantic-ui to your docs. Why did you chose to confuse your community with such answers like "just add another menu". You could just explain your point of view in your docs. Tell to everybody why it's a goodness to have a two separate menus for mobile and wide-screens. Then add working good example and close this issue. What's a problem? Why did you prefer to have opened 4 year old issue?

+1

@finferflu @dawidsappich @AshleyMcVeigh @Gino @guihatano Please use GitHub reactions instead of just posting +1

@nextgensparx I did use the reaction, but then I saw that a lot of people were doing it, so I assumed that was how it worked. Sorry about that.

any working sample repo? It's easy to make grids device visibility responsive but it's hard when you display icon and try to show/hide menus. tsk

+1

+1

+1

Was this page helpful?
0 / 5 - 0 ratings