Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to hide the prev and next button when there is only one slide? #113

Open
willgunadi opened this issue Jun 23, 2020 · 1 comment
Open

Comments

@willgunadi
Copy link

I realize that this component is a slider which means multiple images. But at the moment I only have one. Can I hide the navigation buttons in this case?

@grr14
Copy link

grr14 commented Aug 10, 2020

You can get an ok-looking result using https://github.com/FortAwesome/react-fontawesome

import {
  faChevronLeft,
  faChevronRight,
} from "@fortawesome/free-solid-svg-icons"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"

const hasImages = yourImagesArray.length > 0 ? true : false

<Slider
  previousButton={
    hasImages ? <FontAwesomeIcon icon={faChevronLeft} /> : null
  }
  nextButton={hasImages ? <FontAwesomeIcon icon={faChevronRight} /> : null}
>
  {yourImagesArray.map(img => <div>{img}</div>)}
</Slider>

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

No branches or pull requests

2 participants