Skip to content

Disable prev/next when slides only contain one image? #250

Answered by igordanchenko
ivanyufen asked this question in Q&A
Discussion options

You must be logged in to vote

Certainly. You just need to disable "infinite" carousel mode in this case:

<Lightbox
  carousel={{ finite: slides.length <= 1 }}
  // ...
/>

You can also hide navigation buttons when there is just one slide:

<Lightbox
  carousel={{ finite: slides.length <= 1 }}
  render={{
    buttonPrev: slides.length <= 1 ? () => null : undefined,
    buttonNext: slides.length <= 1 ? () => null : undefined,
  }}
  // ...
/>

This use case is covered in the documentation over here - https://yet-another-react-lightbox.com/customization#HidingNavigationButtons

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by igordanchenko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants