react-swipeable-views
react-swipeable-views copied to clipboard
Question: Is it possible for the height of the swipeable view to limit to the current tab's data?
Hi, I just started using react-swipeable-views, and I am wondering if it is possible for the height of each view to be the height of the content for that specific tab/view? Right now, the height of all the views/tabs is the height of the longest content, and I am wondering if there are any solutions to solve this. Thanks!
Im experiencing the same issue
same issue here
I think u can use the animateHeight
prop to use the height of each view separately.
That works for me! Adding animateHeight
adjusts the height for each tab. For dynamic heights I set the animateheight as false in state then set it as true when the api call had completed
This example works without animateHeight
, I think the trick is to set an additional hidden
prop:
const steps = [ Step1, Step2, Step3, Step4 ]
return (
<SwipeableViews index={activeStep} disabled={true}>
{steps.map((step, index) => {
const Step = step
return (
<div key={index} hidden={index !== activeStep} aria-labelledby={`step-${index}`}>
<Step />
</div>
)
})}
</SwipeableViews>
)