question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Paging with text instead of dots

See original GitHub issue

Hi,

I’m wondering if there is a way to create a custom pagination section, similar to what is being done here on the non-React version of Slick: https://codepen.io/norman_pixelkings/pen/NNbqgG

I’ve tried what’s being done in that Pen and only get slider x as a result of logging slider.

I’ve tried logging props as well and it doesn’t seem like any props are passed to the customPaging.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
kieckhafercommented, Sep 25, 2017

@davidprae I don’t know if this helps, but what I ended up doing was this:

The settings, which populate the custom paging:

const settings = {
      dots: dots,
      draggable: draggable,
      infinite: infinite,
      speed: 500,
      autoplay: false,
      customPaging: function (i) {
        return (
          <a>{pagination[i]}</a>
        );
      },
      prevArrow: prevArrow,
      nextArrow: nextArrow
    };

And then I loop through the data that I pass into the slider anyway, and create a new Array of ‘Labels’ to pass specifically to the customPagination setting:

  const cards = this.state.data;

    const pagination = [];

    if (Array.isArray(cards)) {
      cards.map((card) => {
        pagination.push(card.label);
      });
    }

    return pagination;
3reactions
ayepRahmancommented, Jun 17, 2018

@paschalidi

` const settings = { dots: true, infinite: true, speed: 500, slidesToShow: 1, slidesToScroll: 1, arrows: false, appendDots: dots => { const customDots = React.Children.map(dots, dot => { if (dot.props[‘className’] === ‘slick-active’) { return React.cloneElement(dot, { className: classnames(styles.slickActive), }); } else { return React.cloneElement(dot, { className: classnames(styles.slickNon), }); } });

    return (
      <div>
        <ul className={classnames(styles.slickDots)}> {customDots} </ul>
      </div>
    );
  },
};`

I’ve manage to customise the active classes by using children props classname and the i add my own active classes

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add custom setting (customPaging - replace dots with text)
I'd like to replace the pager dots with text (preferably text from alt or title tag from corresponding slideshow image). I know that...
Read more >
Developers - Custom Paging with text instead of dots -
Hi,. I'm wondering if there is a way to create a custom pagination section, similar to what is being done here on the...
Read more >
javascript - How to add dots between paginated numbers in ...
How to add dots between paginated numbers in pagination only with Pure JS and not with any library or framework? · Subscribe to...
Read more >
How to Build a Custom Pagination Component in React
In this post, we will focus on pagination and we'll build a custom controlled component that handles page buttons based on the current...
Read more >
Custom Paging - React Slick Documentation - neostack
... dots: true, dotsClass: "slick-dots slick-thumb", infinite: true, speed: 500, slidesToShow: 1, slidesToScroll: 1 }; return ( <div> <h2>Custom Paging</h2> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found