How to use owl carousel options in React Owl Carousel?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am new to React JS. I have tried to use owl carousel in React.



The package link I installed from npm is



https://www.npmjs.com/package/react-owl-carousel



As instructed I have imported Owl Carousel component on specific page. Here is the code:



import React, { Component } from 'react';
import {Grid, Row, Col , ProgressBar } from 'react-bootstrap';
import UserAvtar from '../common/UserAvtar.js';
import SectionHeaderOfCards from '../common/SectionHeaderOfCards.js';
import OwlCarousel from 'react-owl-carousel';

const options = {
items: 4,
};

class DashboardPage extends Component {
render() {
return (
<div>
<section className="has-small__padding has-grey__bg">
<UserAvtar />
</section>
<section className="has-small__padding">
<Grid>
<SectionHeaderOfCards title="Recommended Matches" />
<OwlCarousel margin={10} >
<div class="item"><h4>1</h4></div>
<div class="item"><h4>2</h4></div>
<div class="item"><h4>3</h4></div>
<div class="item"><h4>4</h4></div>
<div class="item"><h4>5</h4></div>
<div class="item"><h4>6</h4></div>
</OwlCarousel>
</Grid>
</section>
</div>
);
}
}

export default DashboardPage;


As default This code outputs 3 items at a time (As 3 is the default value in owl carousel) . I thought of I may initialised the value with 4 , hence tried ,



const options = {
items: 4,
};


But it's not working. There is nothing mentioned in its node package either. Anyone knows how to use owl carousel options in React Owl carousel ?



Apart I want to show 3 items for devices between 768px to 1200px , 2 items between 500px to 767px and 1 item for the devices below 499px.



Here is how normal owl carousel use the option to add responsiveness. https://owlcarousel2.github.io/OwlCarousel2/demos/responsive.html



How to achieve the same in React owl carousel ?










share|improve this question

























  • you are not adding the option object to OwlCarousel Component.

    – bennygenel
    Sep 6 '17 at 10:38











  • Anu suggestions to How to add it ?

    – Swapna
    Sep 6 '17 at 10:43






  • 1





    <OwlCarousel margin={10} items={4} > or <OwlCarousel margin={10} {...options} >

    – bennygenel
    Sep 6 '17 at 10:45













  • Check the docs for responsiveClass

    – bennygenel
    Sep 6 '17 at 11:05











  • responsiveClass is not much help. I would rather like to use Owl Carousel option "responsive" .

    – Swapna
    Sep 6 '17 at 12:19


















0















I am new to React JS. I have tried to use owl carousel in React.



The package link I installed from npm is



https://www.npmjs.com/package/react-owl-carousel



As instructed I have imported Owl Carousel component on specific page. Here is the code:



import React, { Component } from 'react';
import {Grid, Row, Col , ProgressBar } from 'react-bootstrap';
import UserAvtar from '../common/UserAvtar.js';
import SectionHeaderOfCards from '../common/SectionHeaderOfCards.js';
import OwlCarousel from 'react-owl-carousel';

const options = {
items: 4,
};

class DashboardPage extends Component {
render() {
return (
<div>
<section className="has-small__padding has-grey__bg">
<UserAvtar />
</section>
<section className="has-small__padding">
<Grid>
<SectionHeaderOfCards title="Recommended Matches" />
<OwlCarousel margin={10} >
<div class="item"><h4>1</h4></div>
<div class="item"><h4>2</h4></div>
<div class="item"><h4>3</h4></div>
<div class="item"><h4>4</h4></div>
<div class="item"><h4>5</h4></div>
<div class="item"><h4>6</h4></div>
</OwlCarousel>
</Grid>
</section>
</div>
);
}
}

export default DashboardPage;


As default This code outputs 3 items at a time (As 3 is the default value in owl carousel) . I thought of I may initialised the value with 4 , hence tried ,



const options = {
items: 4,
};


But it's not working. There is nothing mentioned in its node package either. Anyone knows how to use owl carousel options in React Owl carousel ?



Apart I want to show 3 items for devices between 768px to 1200px , 2 items between 500px to 767px and 1 item for the devices below 499px.



Here is how normal owl carousel use the option to add responsiveness. https://owlcarousel2.github.io/OwlCarousel2/demos/responsive.html



How to achieve the same in React owl carousel ?










share|improve this question

























  • you are not adding the option object to OwlCarousel Component.

    – bennygenel
    Sep 6 '17 at 10:38











  • Anu suggestions to How to add it ?

    – Swapna
    Sep 6 '17 at 10:43






  • 1





    <OwlCarousel margin={10} items={4} > or <OwlCarousel margin={10} {...options} >

    – bennygenel
    Sep 6 '17 at 10:45













  • Check the docs for responsiveClass

    – bennygenel
    Sep 6 '17 at 11:05











  • responsiveClass is not much help. I would rather like to use Owl Carousel option "responsive" .

    – Swapna
    Sep 6 '17 at 12:19














0












0








0








I am new to React JS. I have tried to use owl carousel in React.



The package link I installed from npm is



https://www.npmjs.com/package/react-owl-carousel



As instructed I have imported Owl Carousel component on specific page. Here is the code:



import React, { Component } from 'react';
import {Grid, Row, Col , ProgressBar } from 'react-bootstrap';
import UserAvtar from '../common/UserAvtar.js';
import SectionHeaderOfCards from '../common/SectionHeaderOfCards.js';
import OwlCarousel from 'react-owl-carousel';

const options = {
items: 4,
};

class DashboardPage extends Component {
render() {
return (
<div>
<section className="has-small__padding has-grey__bg">
<UserAvtar />
</section>
<section className="has-small__padding">
<Grid>
<SectionHeaderOfCards title="Recommended Matches" />
<OwlCarousel margin={10} >
<div class="item"><h4>1</h4></div>
<div class="item"><h4>2</h4></div>
<div class="item"><h4>3</h4></div>
<div class="item"><h4>4</h4></div>
<div class="item"><h4>5</h4></div>
<div class="item"><h4>6</h4></div>
</OwlCarousel>
</Grid>
</section>
</div>
);
}
}

export default DashboardPage;


As default This code outputs 3 items at a time (As 3 is the default value in owl carousel) . I thought of I may initialised the value with 4 , hence tried ,



const options = {
items: 4,
};


But it's not working. There is nothing mentioned in its node package either. Anyone knows how to use owl carousel options in React Owl carousel ?



Apart I want to show 3 items for devices between 768px to 1200px , 2 items between 500px to 767px and 1 item for the devices below 499px.



Here is how normal owl carousel use the option to add responsiveness. https://owlcarousel2.github.io/OwlCarousel2/demos/responsive.html



How to achieve the same in React owl carousel ?










share|improve this question
















I am new to React JS. I have tried to use owl carousel in React.



The package link I installed from npm is



https://www.npmjs.com/package/react-owl-carousel



As instructed I have imported Owl Carousel component on specific page. Here is the code:



import React, { Component } from 'react';
import {Grid, Row, Col , ProgressBar } from 'react-bootstrap';
import UserAvtar from '../common/UserAvtar.js';
import SectionHeaderOfCards from '../common/SectionHeaderOfCards.js';
import OwlCarousel from 'react-owl-carousel';

const options = {
items: 4,
};

class DashboardPage extends Component {
render() {
return (
<div>
<section className="has-small__padding has-grey__bg">
<UserAvtar />
</section>
<section className="has-small__padding">
<Grid>
<SectionHeaderOfCards title="Recommended Matches" />
<OwlCarousel margin={10} >
<div class="item"><h4>1</h4></div>
<div class="item"><h4>2</h4></div>
<div class="item"><h4>3</h4></div>
<div class="item"><h4>4</h4></div>
<div class="item"><h4>5</h4></div>
<div class="item"><h4>6</h4></div>
</OwlCarousel>
</Grid>
</section>
</div>
);
}
}

export default DashboardPage;


As default This code outputs 3 items at a time (As 3 is the default value in owl carousel) . I thought of I may initialised the value with 4 , hence tried ,



const options = {
items: 4,
};


But it's not working. There is nothing mentioned in its node package either. Anyone knows how to use owl carousel options in React Owl carousel ?



Apart I want to show 3 items for devices between 768px to 1200px , 2 items between 500px to 767px and 1 item for the devices below 499px.



Here is how normal owl carousel use the option to add responsiveness. https://owlcarousel2.github.io/OwlCarousel2/demos/responsive.html



How to achieve the same in React owl carousel ?







reactjs owl-carousel-2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 6 '17 at 11:02







Swapna

















asked Sep 6 '17 at 10:35









SwapnaSwapna

6081519




6081519













  • you are not adding the option object to OwlCarousel Component.

    – bennygenel
    Sep 6 '17 at 10:38











  • Anu suggestions to How to add it ?

    – Swapna
    Sep 6 '17 at 10:43






  • 1





    <OwlCarousel margin={10} items={4} > or <OwlCarousel margin={10} {...options} >

    – bennygenel
    Sep 6 '17 at 10:45













  • Check the docs for responsiveClass

    – bennygenel
    Sep 6 '17 at 11:05











  • responsiveClass is not much help. I would rather like to use Owl Carousel option "responsive" .

    – Swapna
    Sep 6 '17 at 12:19



















  • you are not adding the option object to OwlCarousel Component.

    – bennygenel
    Sep 6 '17 at 10:38











  • Anu suggestions to How to add it ?

    – Swapna
    Sep 6 '17 at 10:43






  • 1





    <OwlCarousel margin={10} items={4} > or <OwlCarousel margin={10} {...options} >

    – bennygenel
    Sep 6 '17 at 10:45













  • Check the docs for responsiveClass

    – bennygenel
    Sep 6 '17 at 11:05











  • responsiveClass is not much help. I would rather like to use Owl Carousel option "responsive" .

    – Swapna
    Sep 6 '17 at 12:19

















you are not adding the option object to OwlCarousel Component.

– bennygenel
Sep 6 '17 at 10:38





you are not adding the option object to OwlCarousel Component.

– bennygenel
Sep 6 '17 at 10:38













Anu suggestions to How to add it ?

– Swapna
Sep 6 '17 at 10:43





Anu suggestions to How to add it ?

– Swapna
Sep 6 '17 at 10:43




1




1





<OwlCarousel margin={10} items={4} > or <OwlCarousel margin={10} {...options} >

– bennygenel
Sep 6 '17 at 10:45







<OwlCarousel margin={10} items={4} > or <OwlCarousel margin={10} {...options} >

– bennygenel
Sep 6 '17 at 10:45















Check the docs for responsiveClass

– bennygenel
Sep 6 '17 at 11:05





Check the docs for responsiveClass

– bennygenel
Sep 6 '17 at 11:05













responsiveClass is not much help. I would rather like to use Owl Carousel option "responsive" .

– Swapna
Sep 6 '17 at 12:19





responsiveClass is not much help. I would rather like to use Owl Carousel option "responsive" .

– Swapna
Sep 6 '17 at 12:19












2 Answers
2






active

oldest

votes


















4














You need to add options object to OwlCarousel component.



Example:



<OwlCarousel margin={10} items={4} > 
//...
</OwlCarouse>


OR



<OwlCarousel margin={10} {...options} >
//...
</OwlCarouse>





share|improve this answer
























  • A small help further please : Want to add responsive option for different break point ? Any suggestions ? or want me to create a separate question ?

    – Swapna
    Sep 6 '17 at 10:55











  • you can create a state object with the default values for the options and then update the state with the desired way of yours. this way you can set the options like this <OwlCarousel margin={10} {...this.state.options} >. If you explain it a little bit more I can update my answer.

    – bennygenel
    Sep 6 '17 at 10:58













  • Edited question.

    – Swapna
    Sep 6 '17 at 11:03



















1














Best you can use:



render() {
const options = {
items: 1,
nav: true,
navText:["<div className='nav-btn prev-slide'></div>","<div className='nav-btn next-slide'></div>"],
rewind: true,
autoplay: true,
slideBy: 1,
dots: true,
dotsEach: true,
dotData: true
};

return (
<OwlCarousel ref="gallery" options={options}>
...
</OwlCarousel>
)





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46073041%2fhow-to-use-owl-carousel-options-in-react-owl-carousel%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    You need to add options object to OwlCarousel component.



    Example:



    <OwlCarousel margin={10} items={4} > 
    //...
    </OwlCarouse>


    OR



    <OwlCarousel margin={10} {...options} >
    //...
    </OwlCarouse>





    share|improve this answer
























    • A small help further please : Want to add responsive option for different break point ? Any suggestions ? or want me to create a separate question ?

      – Swapna
      Sep 6 '17 at 10:55











    • you can create a state object with the default values for the options and then update the state with the desired way of yours. this way you can set the options like this <OwlCarousel margin={10} {...this.state.options} >. If you explain it a little bit more I can update my answer.

      – bennygenel
      Sep 6 '17 at 10:58













    • Edited question.

      – Swapna
      Sep 6 '17 at 11:03
















    4














    You need to add options object to OwlCarousel component.



    Example:



    <OwlCarousel margin={10} items={4} > 
    //...
    </OwlCarouse>


    OR



    <OwlCarousel margin={10} {...options} >
    //...
    </OwlCarouse>





    share|improve this answer
























    • A small help further please : Want to add responsive option for different break point ? Any suggestions ? or want me to create a separate question ?

      – Swapna
      Sep 6 '17 at 10:55











    • you can create a state object with the default values for the options and then update the state with the desired way of yours. this way you can set the options like this <OwlCarousel margin={10} {...this.state.options} >. If you explain it a little bit more I can update my answer.

      – bennygenel
      Sep 6 '17 at 10:58













    • Edited question.

      – Swapna
      Sep 6 '17 at 11:03














    4












    4








    4







    You need to add options object to OwlCarousel component.



    Example:



    <OwlCarousel margin={10} items={4} > 
    //...
    </OwlCarouse>


    OR



    <OwlCarousel margin={10} {...options} >
    //...
    </OwlCarouse>





    share|improve this answer













    You need to add options object to OwlCarousel component.



    Example:



    <OwlCarousel margin={10} items={4} > 
    //...
    </OwlCarouse>


    OR



    <OwlCarousel margin={10} {...options} >
    //...
    </OwlCarouse>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Sep 6 '17 at 10:52









    bennygenelbennygenel

    13.2k32750




    13.2k32750













    • A small help further please : Want to add responsive option for different break point ? Any suggestions ? or want me to create a separate question ?

      – Swapna
      Sep 6 '17 at 10:55











    • you can create a state object with the default values for the options and then update the state with the desired way of yours. this way you can set the options like this <OwlCarousel margin={10} {...this.state.options} >. If you explain it a little bit more I can update my answer.

      – bennygenel
      Sep 6 '17 at 10:58













    • Edited question.

      – Swapna
      Sep 6 '17 at 11:03



















    • A small help further please : Want to add responsive option for different break point ? Any suggestions ? or want me to create a separate question ?

      – Swapna
      Sep 6 '17 at 10:55











    • you can create a state object with the default values for the options and then update the state with the desired way of yours. this way you can set the options like this <OwlCarousel margin={10} {...this.state.options} >. If you explain it a little bit more I can update my answer.

      – bennygenel
      Sep 6 '17 at 10:58













    • Edited question.

      – Swapna
      Sep 6 '17 at 11:03

















    A small help further please : Want to add responsive option for different break point ? Any suggestions ? or want me to create a separate question ?

    – Swapna
    Sep 6 '17 at 10:55





    A small help further please : Want to add responsive option for different break point ? Any suggestions ? or want me to create a separate question ?

    – Swapna
    Sep 6 '17 at 10:55













    you can create a state object with the default values for the options and then update the state with the desired way of yours. this way you can set the options like this <OwlCarousel margin={10} {...this.state.options} >. If you explain it a little bit more I can update my answer.

    – bennygenel
    Sep 6 '17 at 10:58







    you can create a state object with the default values for the options and then update the state with the desired way of yours. this way you can set the options like this <OwlCarousel margin={10} {...this.state.options} >. If you explain it a little bit more I can update my answer.

    – bennygenel
    Sep 6 '17 at 10:58















    Edited question.

    – Swapna
    Sep 6 '17 at 11:03





    Edited question.

    – Swapna
    Sep 6 '17 at 11:03













    1














    Best you can use:



    render() {
    const options = {
    items: 1,
    nav: true,
    navText:["<div className='nav-btn prev-slide'></div>","<div className='nav-btn next-slide'></div>"],
    rewind: true,
    autoplay: true,
    slideBy: 1,
    dots: true,
    dotsEach: true,
    dotData: true
    };

    return (
    <OwlCarousel ref="gallery" options={options}>
    ...
    </OwlCarousel>
    )





    share|improve this answer




























      1














      Best you can use:



      render() {
      const options = {
      items: 1,
      nav: true,
      navText:["<div className='nav-btn prev-slide'></div>","<div className='nav-btn next-slide'></div>"],
      rewind: true,
      autoplay: true,
      slideBy: 1,
      dots: true,
      dotsEach: true,
      dotData: true
      };

      return (
      <OwlCarousel ref="gallery" options={options}>
      ...
      </OwlCarousel>
      )





      share|improve this answer


























        1












        1








        1







        Best you can use:



        render() {
        const options = {
        items: 1,
        nav: true,
        navText:["<div className='nav-btn prev-slide'></div>","<div className='nav-btn next-slide'></div>"],
        rewind: true,
        autoplay: true,
        slideBy: 1,
        dots: true,
        dotsEach: true,
        dotData: true
        };

        return (
        <OwlCarousel ref="gallery" options={options}>
        ...
        </OwlCarousel>
        )





        share|improve this answer













        Best you can use:



        render() {
        const options = {
        items: 1,
        nav: true,
        navText:["<div className='nav-btn prev-slide'></div>","<div className='nav-btn next-slide'></div>"],
        rewind: true,
        autoplay: true,
        slideBy: 1,
        dots: true,
        dotsEach: true,
        dotData: true
        };

        return (
        <OwlCarousel ref="gallery" options={options}>
        ...
        </OwlCarousel>
        )






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 11:36









        Kapil ChhabraKapil Chhabra

        1323




        1323






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46073041%2fhow-to-use-owl-carousel-options-in-react-owl-carousel%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Paul Cézanne

            UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

            Angular material date-picker (MatDatepicker) auto completes the date on focus out