react-tabs icon indicating copy to clipboard operation
react-tabs copied to clipboard

Responsive?

Open rohan-deshpande opened this issue 9 years ago • 20 comments

Great component!

Any thoughts on making these responsive? There's some nice ideas here using Bootstrap 3 tabs.

rohan-deshpande avatar Oct 16 '16 07:10 rohan-deshpande

@rohan-deshpande by the time I'm using https://github.com/maslianok/react-responsive-tabs

dmitry avatar Oct 21 '16 08:10 dmitry

my preference is to transform into a drop down rather than accordion (for mobile scenarios) eg https://codepen.io/jpkempf/details/Awxbo

sgilligan avatar Apr 30 '17 08:04 sgilligan

What if dropdown is too long?

dmitry avatar May 02 '17 07:05 dmitry

yes, the dropdown would need some smarts to make it scrollable if there were too many elements for the available space.

sgilligan avatar May 03 '17 01:05 sgilligan

I just ran into this issue as well. This library does everything a tabsheet needs to do (and does it nicely) except for proper overflow handling. I guess this has to be some CSS media query magic in the background to make it happen?

I'm fine with either the dropdown or left/right scroll buttons (slight preference for the dropdown). I just would like to avoid:

  • tabs becoming unreachable for the user (except by resizing the window)
  • showing the vanilla browser scrollbar

MartinHaeusler avatar May 26 '17 20:05 MartinHaeusler

Any plans to make this responsive?

stephen-oconnor avatar May 31 '17 10:05 stephen-oconnor

For those that are interested, I did fork this repo to make a responsive version similar to what @sgilligan posted: https://github.com/localmotors/react-tabs

You can see in action: https://launchforth.io/styleguide/react/

bmsterling avatar Aug 02 '17 15:08 bmsterling

nice! exactly what I was looking for. @dmitry if the drop down is long, it wouldn't be any different to the length of an accordion style implementation. I like the implementation from @bmsterling as when selected, the UI is keep minimal which is great on mobile.

sgilligan avatar Aug 04 '17 00:08 sgilligan

Any plans for forking the changes back into this repo? Would be nice.

grawlinson avatar Aug 20 '17 03:08 grawlinson

@bmsterling I think this can be done now with react-tabs itself by simply doing.

<Tabs>
  <div className="react-tabs__menu is--open">
    <TabList> ... </TabList>
  </div>
  <TabPanel>content</TabPanel>
</Tabs>

or as HOC:


export default function MyTabList(props) {
  return (
    <div className="react-tabs__menu is--open">
      <TabList>{props.children}</TabList>
    </div>
  );
}

MyTabList.tabsRole = 'TabList';

And it needs the css changes obviously. It would be nice to have an example in the repo that shows how this works, but I currently don't have time to do that.

danez avatar Sep 19 '17 22:09 danez

@danez thanks, I'll give it a pass this week.

bmsterling avatar Sep 19 '17 23:09 bmsterling

is this task still relevant?

Frozzy6 avatar Jan 31 '18 10:01 Frozzy6

I'm more into horizontal scrolling on mobile, simply adding:

@media (your-own-screen-restrictions) {
  .react-tabs__tab-list {
      display: block;
      overflow-y: auto;
      width: 100%;
      white-space: nowrap;
  }
}

brunocramos avatar Sep 21 '18 15:09 brunocramos

The last example by @brunocramos i'm afraid is vertical, no horizontal. I've tried many different ways and there is no way to make TabList horizontally-scrolled. Anything, please, despite almost 3 years have past since the last comment?? 🙏

KoolTheba avatar Jun 23 '21 17:06 KoolTheba

@KoolTheba you can try the following snippet:

.react-tabs__tab-list {
  display: flex;
  overflow-x: auto;
}

joepvl avatar Jun 29 '21 20:06 joepvl

Are there any plans to build this into the main lib? It's been over a year since the last response.

TechStudent10 avatar Jan 15 '23 04:01 TechStudent10

@TechStudent10 no, it's out of scope. Using some of the code from this thread you should be able to do it yourself without much fuss.

joepvl avatar Jan 16 '23 10:01 joepvl

I find it hard to believe that in 2023 (even when this thread was created all the way back in 2016) that responsive support is "out of scope". I mean ... you should be mobile first in fact...

jpveilleux avatar Jul 17 '23 17:07 jpveilleux

@joepvl how do you enable horizontal scroll on <TabPanel />

deflexable avatar Aug 08 '23 12:08 deflexable

@deflexable this is an HTML/CSS question, not a React Tabs question. If I were learning CSS now while trying to answer this question for myself I'd start by figuring out how to get any container to scroll its content horizontally. My first go-to would be these properties and values:

 display: flex;
 white-space: nowrap; 
 overflow-x: auto;

But I'm sure there are other ways to do it, depending on your exact use case.

@jpveilleux I understand that you'd like for this library to support your use case without any fuss, but from my point of view it's not the "responsive support" that's out of scope — it's supported, there is nothing stopping consumers from writing responsive CSS for the DOM structures generated by this library. What is out of scope is adding opinionated CSS that prescribes a specific way of making tabs responsive. That is not what this library is about.

joepvl avatar Aug 08 '23 13:08 joepvl