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

Horizontal scroll for tabs

Open maxclaus opened this issue 9 years ago • 9 comments

I have a case where I would need to scroll horizontally because there are too many open tabs. Would you be interested if I prepare a PR adding support for it? Mockup:

< | tab 1 | tab 2 | tab 3 | tab 4 | > 
-------------------------------------
|              Panel                |
-------------------------------------

PS: The scroll would be only for the TabList.

maxclaus avatar Sep 23 '16 01:09 maxclaus

This one is part of the responsiveness: https://github.com/reactjs/react-tabs/issues/142

dmitry avatar Oct 21 '16 08:10 dmitry

In my case a horizontal scroll with button left/right works better than the approach used by that library with "show more" and accordion.

maxclaus avatar Oct 21 '16 08:10 maxclaus

I think it's out of scope. It's better to allow for wrapping TabList in a higher order components, use higher order components for tabs and thus different scrolling strategies can be implemented for specific use case.

karevn avatar Aug 13 '17 20:08 karevn

I achieved this by using react-slick library and wrapping Tabs inside Slider.

ZowWeb avatar Jul 29 '20 13:07 ZowWeb

@ZowWeb, how did you do that? I get error: Failed prop type: Invalid prop tabIndex of type number supplied to Tab, expected string. Structure is the following:

                  <TabList>

                     <Slider {...sliderProps}>
                         <Tab>1</Tab>
                         <Tab>2</Tab>
                         <Tab>3</Tab>
                    </Slider>
                     
                 </TabList>

berpcor avatar Nov 15 '20 06:11 berpcor

Any update on this?

TechStudent10 avatar Jan 11 '23 20:01 TechStudent10

let me know if this works for you!

import { Tabs, Tab, TabList, TabPanel } from 'react-tabs'
import Slider from 'react-slick'

<Tabs>
  <TabList>
    <Slider {...settings}>
      {items.map((item, i) => <Fragment key={i}><Tab>{item.title}</Tab></Fragment>)}
    </Slider>
  </TabList>
  {items.map((item, i) => <TabPanel key={i} dangerouslySetInnerHTML={{ __html: item.content }} />)}
</Tabs>

ZowWeb avatar Jan 13 '23 04:01 ZowWeb

let me know if this works for you!

import { Tabs, Tab, TabList, TabPanel } from 'react-tabs'
import Slider from 'react-slick'

<Tabs>
  <TabList>
    <Slider {...settings}>
      {items.map((item, i) => <Fragment key={i}><Tab>{item.title}</Tab></Fragment>)}
    </Slider>
  </TabList>
  {items.map((item, i) => <TabPanel key={i} dangerouslySetInnerHTML={{ __html: item.content }} />)}
</Tabs>

Nope, styling gets messed up.

TechStudent10 avatar Jan 15 '23 04:01 TechStudent10

make Slider flex, should prob fix ur styling issues. If it doesn't, feel free to share before/after how the styling looks

ZowWeb avatar Jan 16 '23 07:01 ZowWeb