Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Centered tabs #1992

Closed
remicastaing opened this issue Mar 21, 2015 · 28 comments
Closed

Centered tabs #1992

remicastaing opened this issue Mar 21, 2015 · 28 comments
Milestone

Comments

@remicastaing
Copy link

Is there a way to center tabs like in G+?

capture d ecran 2015-03-21 10 06 47

@bonatoc
Copy link

bonatoc commented Mar 23, 2015

On line 48 of https://github.com/angular/material/blob/master/src/components/tabs/tabs.scss,
it looks like center is an (ng-)attribute of md-tabs.

I have no time to try it right now, but I would like if you give me some feedback if you test it, thank you.

@bonatoc
Copy link

bonatoc commented Mar 23, 2015

I think you can "only" stretch them, see the doc.

So maybe you can place them into another fixed-width container that is centered (think flexbox), so the tabs do not stretch on all the topnav's width, like in the example you are showing.

@bonatoc
Copy link

bonatoc commented Mar 23, 2015

OK I think I have it. See this codepen and please let me know.

@remicastaing
Copy link
Author

It works well. Thank you, @bonatoc for taking the time.

I adapted your code a little for small sized screen: codepen.

@remicastaing
Copy link
Author

Should we keep this issue open and tagged as improvement?

@bonatoc
Copy link

bonatoc commented Mar 24, 2015

I'm not sure.

We could contribute by making a md-centered-tabs attribute following the "wrapped-inside-centered-container" method in the codepen above and request a pull.

But I think the md-stretch-tabs attribute already does the job.
Frameworks are there to be hacked, worked with.
We can't expect them to have all the options, and I don't think it is the way to go. You end up overbloating it (see Bootstrap...).

@bonatoc
Copy link

bonatoc commented Mar 30, 2015

Maybe you could tagged the issue as improvement for the demos ?

Many devs would like the centered tabs option displayed as an example.

Can we fork the docs a make a pull request on the demos?

@remicastaing
Copy link
Author

I tried to write a simple md-centered-tabs directive, but it is not simple. I gave up.

Your solution, @bonatoc, should be kept somewhere. She's very useful.

@robertmesserle
Copy link
Contributor

Support for centered tabs is on my list, and I will be hopefully getting to this today.

@robertmesserle robertmesserle added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Mar 31, 2015
@ajoslin ajoslin removed the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Apr 1, 2015
@remicastaing
Copy link
Author

Awesome @robertmesserle. And again, thanks @bonatoc.

@bonatoc
Copy link

bonatoc commented Apr 1, 2015

Awesome @robertmesserle

@remicastaing , you're welcome. I was on the same issue myself.

JulianWielga pushed a commit to JulianWielga/material that referenced this issue Apr 1, 2015
@d668
Copy link

d668 commented Jan 13, 2016

both codepens don't work for me

so can i use centered tabs?

@bonatoc
Copy link

bonatoc commented Jan 14, 2016

@super-coder — if you're super, please provide more info: version, specific problem?

@d668
Copy link

d668 commented Jan 14, 2016

image

image

@prasad47
Copy link

prasad47 commented Mar 8, 2016

md-center-tabs="true" did the trick just like that FYI

@d668
Copy link

d668 commented Mar 22, 2016

i submitted an issue #7695, tabs are hidden after reload on IE on XS screen

@bonatoc
Copy link

bonatoc commented Mar 25, 2016

@super-coder — Please provide IE version.

@d668
Copy link

d668 commented Mar 25, 2016

@bonatoc what do you mean? you don't understand how code doesn't work in IE?? There is no IE version

@bonatoc
Copy link

bonatoc commented Mar 26, 2016

"There is no IE version" - I beg your pardon?

@d668
Copy link

d668 commented Mar 26, 2016

@bonatoc you can see the screen in #7695

@bonatoc
Copy link

bonatoc commented Mar 26, 2016

Like tagged: "need more info".

@d668
Copy link

d668 commented Mar 26, 2016

added more info there

@YonathanMeguira
Copy link

just for you to know this works wonders as well

@YonathanMeguira
Copy link

here's the working code
<md-center-tabs> <md-tabs md-cnter-tabs="true" md-dynamic-height md-border-bottom> <md-tab label="Policy Dashboard"> <md-content class="md-padding"> <h1 class="md-display-2">Policy Dashboard</h1> <p>{{lorem}}</p> </md-content> </md-tab> <md-tab label="What is this policy?"> <md-content class="md-padding"> <h1 class="md-display-2">What is this policy?</h1> <p>{{lorem}}</p> </md-content> </md-tab> <md-tab label="Who uses this Policy?"> <md-content class="md-padding"> <h1 class="md-display-2">Who uses this Policy?</h1> <p>{{lorem}}</p> </md-content> </md-tab> </md-tabs> </md-center-tabs>

@YonathanMeguira
Copy link

replace ({lorem}} by the content of your choice of course

@TXZdream
Copy link

Just add md-center-tabs="true" in md-tabs is OK, jonathanmeguira's code doesn't work because he spell mistake 'center'.

@YonathanMeguira
Copy link

my bad @TXZdream

@Zwilla
Copy link

Zwilla commented Sep 27, 2017

open angular.material.js and search for: material.components.tabs
there you will find everything about the tabs and how they work.

Source Code

build*

EXAMPLE:
<md-tabs mdTabScroll md-align-tabs="top" md-selected="0" md-dynamic-height md-border-bottom layout-fill md-stretch-tabs="always" md-center-tabs md-swipe-content>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants