ReactJS: Create isolated component with own cssCreate GUID / UUID in JavaScript?Set cellpadding and cellspacing in CSS?Creating multiline strings in JavaScriptHow do I give text or an image a transparent background using CSS?Is there a CSS parent selector?When to use margin vs padding in CSSChange an HTML5 input's placeholder color with CSSHow do CSS triangles work?How do I vertically center text with CSS?Is it possible to apply CSS to half of a character?

Has there ever been an airliner design involving reducing generator load by installing solar panels?

Stopping power of mountain vs road bike

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Intersection of two sorted vectors in C++

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

What's the difference between 'rename' and 'mv'?

I Accidentally Deleted a Stock Terminal Theme

Modeling an IP Address

Can I ask the recruiters in my resume to put the reason why I am rejected?

Can a rocket refuel on Mars from water?

Why are electrically insulating heatsinks so rare? Is it just cost?

90's TV series where a boy goes to another dimension through portal near power lines

Will google still index a page if I use a $_SESSION variable?

Western buddy movie with a supernatural twist where a woman turns into an eagle at the end

Is the Joker left-handed?

What does it mean to describe someone as a butt steak?

Assassin's bullet with mercury

Is "remove commented out code" correct English?

What is a clear way to write a bar that has an extra beat?

Blender 2.8 I can't see vertices, edges or faces in edit mode

What is the word for reserving something for yourself before others do?

How to prevent "they're falling in love" trope

Fully-Firstable Anagram Sets

Can a virus destroy the BIOS of a modern computer?



ReactJS: Create isolated component with own css


Create GUID / UUID in JavaScript?Set cellpadding and cellspacing in CSS?Creating multiline strings in JavaScriptHow do I give text or an image a transparent background using CSS?Is there a CSS parent selector?When to use margin vs padding in CSSChange an HTML5 input's placeholder color with CSSHow do CSS triangles work?How do I vertically center text with CSS?Is it possible to apply CSS to half of a character?






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








4















I'm trying to develop a library of reactjs components in order to be reusable by different projects.



This components besides the functionality itself, must have a theme with different css styles.



I could write a css file, but then I must import the css in every project I will use any of that components. I need to set the style of this components inside itself, so when I import it in other project, I will looks exactly as I expect.



Is there any ReactJS library (or plugin perhaps?) to compile this styles inside the component or maybe apply a style on the componentDidMount?



EDIT



I forgot to add that I'm using MaterialUI. which is a framework that implements Material Design for React.



It provides different components which it own styles, and I can modify some of them, but not all.



Since Material UI create a big HTML I cannot add inline styles, that's why I need to add a selector to apply styles from React directly



Meterial UI provides something like that, so I guess is possible. This is how I configure in Material UI



const muiTheme = getMuiTheme(
palette:
textColor: cyan500,
,
appBar:
height: 50,
,
);


Sadly only some styles are supported by this, and not all I need










share|improve this question
























  • what's wrong with inline styles?

    – ZekeDroid
    Mar 31 '16 at 14:33











  • sorry, forgot that part. I'm using materialUI (material-ui.com) for some of that elements, which has it own stylesheets and full HTML rendered inside that library. I can add a class or inline-style to the main container of that compoents, but I cannot go deeper with the inline styles

    – Pablo
    Mar 31 '16 at 14:46











  • so you absolutely need to somehow import css FILES into your component is what you're saying?

    – ZekeDroid
    Mar 31 '16 at 14:52











  • Yes import css in the component. Or maybe apply style some how as jquery does $('selector').css(...) is there anything like that for React?

    – Pablo
    Mar 31 '16 at 14:53

















4















I'm trying to develop a library of reactjs components in order to be reusable by different projects.



This components besides the functionality itself, must have a theme with different css styles.



I could write a css file, but then I must import the css in every project I will use any of that components. I need to set the style of this components inside itself, so when I import it in other project, I will looks exactly as I expect.



Is there any ReactJS library (or plugin perhaps?) to compile this styles inside the component or maybe apply a style on the componentDidMount?



EDIT



I forgot to add that I'm using MaterialUI. which is a framework that implements Material Design for React.



It provides different components which it own styles, and I can modify some of them, but not all.



Since Material UI create a big HTML I cannot add inline styles, that's why I need to add a selector to apply styles from React directly



Meterial UI provides something like that, so I guess is possible. This is how I configure in Material UI



const muiTheme = getMuiTheme(
palette:
textColor: cyan500,
,
appBar:
height: 50,
,
);


Sadly only some styles are supported by this, and not all I need










share|improve this question
























  • what's wrong with inline styles?

    – ZekeDroid
    Mar 31 '16 at 14:33











  • sorry, forgot that part. I'm using materialUI (material-ui.com) for some of that elements, which has it own stylesheets and full HTML rendered inside that library. I can add a class or inline-style to the main container of that compoents, but I cannot go deeper with the inline styles

    – Pablo
    Mar 31 '16 at 14:46











  • so you absolutely need to somehow import css FILES into your component is what you're saying?

    – ZekeDroid
    Mar 31 '16 at 14:52











  • Yes import css in the component. Or maybe apply style some how as jquery does $('selector').css(...) is there anything like that for React?

    – Pablo
    Mar 31 '16 at 14:53













4












4








4


1






I'm trying to develop a library of reactjs components in order to be reusable by different projects.



This components besides the functionality itself, must have a theme with different css styles.



I could write a css file, but then I must import the css in every project I will use any of that components. I need to set the style of this components inside itself, so when I import it in other project, I will looks exactly as I expect.



Is there any ReactJS library (or plugin perhaps?) to compile this styles inside the component or maybe apply a style on the componentDidMount?



EDIT



I forgot to add that I'm using MaterialUI. which is a framework that implements Material Design for React.



It provides different components which it own styles, and I can modify some of them, but not all.



Since Material UI create a big HTML I cannot add inline styles, that's why I need to add a selector to apply styles from React directly



Meterial UI provides something like that, so I guess is possible. This is how I configure in Material UI



const muiTheme = getMuiTheme(
palette:
textColor: cyan500,
,
appBar:
height: 50,
,
);


Sadly only some styles are supported by this, and not all I need










share|improve this question
















I'm trying to develop a library of reactjs components in order to be reusable by different projects.



This components besides the functionality itself, must have a theme with different css styles.



I could write a css file, but then I must import the css in every project I will use any of that components. I need to set the style of this components inside itself, so when I import it in other project, I will looks exactly as I expect.



Is there any ReactJS library (or plugin perhaps?) to compile this styles inside the component or maybe apply a style on the componentDidMount?



EDIT



I forgot to add that I'm using MaterialUI. which is a framework that implements Material Design for React.



It provides different components which it own styles, and I can modify some of them, but not all.



Since Material UI create a big HTML I cannot add inline styles, that's why I need to add a selector to apply styles from React directly



Meterial UI provides something like that, so I guess is possible. This is how I configure in Material UI



const muiTheme = getMuiTheme(
palette:
textColor: cyan500,
,
appBar:
height: 50,
,
);


Sadly only some styles are supported by this, and not all I need







javascript css reactjs dom material-ui






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 3:10









lazaruslarue

10912




10912










asked Mar 31 '16 at 14:30









PabloPablo

1,79793257




1,79793257












  • what's wrong with inline styles?

    – ZekeDroid
    Mar 31 '16 at 14:33











  • sorry, forgot that part. I'm using materialUI (material-ui.com) for some of that elements, which has it own stylesheets and full HTML rendered inside that library. I can add a class or inline-style to the main container of that compoents, but I cannot go deeper with the inline styles

    – Pablo
    Mar 31 '16 at 14:46











  • so you absolutely need to somehow import css FILES into your component is what you're saying?

    – ZekeDroid
    Mar 31 '16 at 14:52











  • Yes import css in the component. Or maybe apply style some how as jquery does $('selector').css(...) is there anything like that for React?

    – Pablo
    Mar 31 '16 at 14:53

















  • what's wrong with inline styles?

    – ZekeDroid
    Mar 31 '16 at 14:33











  • sorry, forgot that part. I'm using materialUI (material-ui.com) for some of that elements, which has it own stylesheets and full HTML rendered inside that library. I can add a class or inline-style to the main container of that compoents, but I cannot go deeper with the inline styles

    – Pablo
    Mar 31 '16 at 14:46











  • so you absolutely need to somehow import css FILES into your component is what you're saying?

    – ZekeDroid
    Mar 31 '16 at 14:52











  • Yes import css in the component. Or maybe apply style some how as jquery does $('selector').css(...) is there anything like that for React?

    – Pablo
    Mar 31 '16 at 14:53
















what's wrong with inline styles?

– ZekeDroid
Mar 31 '16 at 14:33





what's wrong with inline styles?

– ZekeDroid
Mar 31 '16 at 14:33













sorry, forgot that part. I'm using materialUI (material-ui.com) for some of that elements, which has it own stylesheets and full HTML rendered inside that library. I can add a class or inline-style to the main container of that compoents, but I cannot go deeper with the inline styles

– Pablo
Mar 31 '16 at 14:46





sorry, forgot that part. I'm using materialUI (material-ui.com) for some of that elements, which has it own stylesheets and full HTML rendered inside that library. I can add a class or inline-style to the main container of that compoents, but I cannot go deeper with the inline styles

– Pablo
Mar 31 '16 at 14:46













so you absolutely need to somehow import css FILES into your component is what you're saying?

– ZekeDroid
Mar 31 '16 at 14:52





so you absolutely need to somehow import css FILES into your component is what you're saying?

– ZekeDroid
Mar 31 '16 at 14:52













Yes import css in the component. Or maybe apply style some how as jquery does $('selector').css(...) is there anything like that for React?

– Pablo
Mar 31 '16 at 14:53





Yes import css in the component. Or maybe apply style some how as jquery does $('selector').css(...) is there anything like that for React?

– Pablo
Mar 31 '16 at 14:53












3 Answers
3






active

oldest

votes


















2














If you use webpack for your transpiling, you can create a separate stylesheet for the component and then import it.



Example:



import './componentStyle.css';


Then setup your component style in that CSS. The component would need both the jsx and css files each time you use them in different projects, but you can easily customize the css for each project if you need, and you can use css classes instead of inline styles.



Your webpack.config.js would need to have this:



module: 
loaders: [
test: /.css$/, loader: 'style-loader!css-loader'
]






share|improve this answer


















  • 1





    As far as I can tell this doesn't isolate the CSS. It applies everywhere unless you use some sort of custom naming convention.

    – James Hancock
    Apr 9 '18 at 18:38


















0














MaterialUI now includes CSS-in-JS docs functionality that will allow you to do just what you're asking.



you probably want to do something like what they suggest and make use of their HOC API:



import React from 'react';
import PropTypes from 'prop-types';
import withStyles from '@material-ui/styles';
import Button from '@material-ui/core/Button';

const styles =
root:
background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
border: 0,
borderRadius: 3,
boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
color: 'white',
height: 48,
padding: '0 30px',
,
;

function HigherOrderComponent(props)
const classes = props;
return <Button className=classes.root>Higher-order component</Button>;


HigherOrderComponent.propTypes =
classes: PropTypes.object.isRequired,
;

export default withStyles(styles)(HigherOrderComponent);





share|improve this answer






























    0














    If you created application with npx create-react-app then



    1. Import your styles from *.module.css file. Example: import styles from './component.module.css' with content .ssss color: red

    2. Apply your style using styles.ssss. Example: <div className=styles.ssss>





    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%2f36336335%2freactjs-create-isolated-component-with-own-css%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      If you use webpack for your transpiling, you can create a separate stylesheet for the component and then import it.



      Example:



      import './componentStyle.css';


      Then setup your component style in that CSS. The component would need both the jsx and css files each time you use them in different projects, but you can easily customize the css for each project if you need, and you can use css classes instead of inline styles.



      Your webpack.config.js would need to have this:



      module: 
      loaders: [
      test: /.css$/, loader: 'style-loader!css-loader'
      ]






      share|improve this answer


















      • 1





        As far as I can tell this doesn't isolate the CSS. It applies everywhere unless you use some sort of custom naming convention.

        – James Hancock
        Apr 9 '18 at 18:38















      2














      If you use webpack for your transpiling, you can create a separate stylesheet for the component and then import it.



      Example:



      import './componentStyle.css';


      Then setup your component style in that CSS. The component would need both the jsx and css files each time you use them in different projects, but you can easily customize the css for each project if you need, and you can use css classes instead of inline styles.



      Your webpack.config.js would need to have this:



      module: 
      loaders: [
      test: /.css$/, loader: 'style-loader!css-loader'
      ]






      share|improve this answer


















      • 1





        As far as I can tell this doesn't isolate the CSS. It applies everywhere unless you use some sort of custom naming convention.

        – James Hancock
        Apr 9 '18 at 18:38













      2












      2








      2







      If you use webpack for your transpiling, you can create a separate stylesheet for the component and then import it.



      Example:



      import './componentStyle.css';


      Then setup your component style in that CSS. The component would need both the jsx and css files each time you use them in different projects, but you can easily customize the css for each project if you need, and you can use css classes instead of inline styles.



      Your webpack.config.js would need to have this:



      module: 
      loaders: [
      test: /.css$/, loader: 'style-loader!css-loader'
      ]






      share|improve this answer













      If you use webpack for your transpiling, you can create a separate stylesheet for the component and then import it.



      Example:



      import './componentStyle.css';


      Then setup your component style in that CSS. The component would need both the jsx and css files each time you use them in different projects, but you can easily customize the css for each project if you need, and you can use css classes instead of inline styles.



      Your webpack.config.js would need to have this:



      module: 
      loaders: [
      test: /.css$/, loader: 'style-loader!css-loader'
      ]







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Mar 31 '16 at 14:55









      Kelly Keller-HeikkilaKelly Keller-Heikkila

      1,76851728




      1,76851728







      • 1





        As far as I can tell this doesn't isolate the CSS. It applies everywhere unless you use some sort of custom naming convention.

        – James Hancock
        Apr 9 '18 at 18:38












      • 1





        As far as I can tell this doesn't isolate the CSS. It applies everywhere unless you use some sort of custom naming convention.

        – James Hancock
        Apr 9 '18 at 18:38







      1




      1





      As far as I can tell this doesn't isolate the CSS. It applies everywhere unless you use some sort of custom naming convention.

      – James Hancock
      Apr 9 '18 at 18:38





      As far as I can tell this doesn't isolate the CSS. It applies everywhere unless you use some sort of custom naming convention.

      – James Hancock
      Apr 9 '18 at 18:38













      0














      MaterialUI now includes CSS-in-JS docs functionality that will allow you to do just what you're asking.



      you probably want to do something like what they suggest and make use of their HOC API:



      import React from 'react';
      import PropTypes from 'prop-types';
      import withStyles from '@material-ui/styles';
      import Button from '@material-ui/core/Button';

      const styles =
      root:
      background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
      border: 0,
      borderRadius: 3,
      boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
      color: 'white',
      height: 48,
      padding: '0 30px',
      ,
      ;

      function HigherOrderComponent(props)
      const classes = props;
      return <Button className=classes.root>Higher-order component</Button>;


      HigherOrderComponent.propTypes =
      classes: PropTypes.object.isRequired,
      ;

      export default withStyles(styles)(HigherOrderComponent);





      share|improve this answer



























        0














        MaterialUI now includes CSS-in-JS docs functionality that will allow you to do just what you're asking.



        you probably want to do something like what they suggest and make use of their HOC API:



        import React from 'react';
        import PropTypes from 'prop-types';
        import withStyles from '@material-ui/styles';
        import Button from '@material-ui/core/Button';

        const styles =
        root:
        background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
        border: 0,
        borderRadius: 3,
        boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
        color: 'white',
        height: 48,
        padding: '0 30px',
        ,
        ;

        function HigherOrderComponent(props)
        const classes = props;
        return <Button className=classes.root>Higher-order component</Button>;


        HigherOrderComponent.propTypes =
        classes: PropTypes.object.isRequired,
        ;

        export default withStyles(styles)(HigherOrderComponent);





        share|improve this answer

























          0












          0








          0







          MaterialUI now includes CSS-in-JS docs functionality that will allow you to do just what you're asking.



          you probably want to do something like what they suggest and make use of their HOC API:



          import React from 'react';
          import PropTypes from 'prop-types';
          import withStyles from '@material-ui/styles';
          import Button from '@material-ui/core/Button';

          const styles =
          root:
          background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
          border: 0,
          borderRadius: 3,
          boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
          color: 'white',
          height: 48,
          padding: '0 30px',
          ,
          ;

          function HigherOrderComponent(props)
          const classes = props;
          return <Button className=classes.root>Higher-order component</Button>;


          HigherOrderComponent.propTypes =
          classes: PropTypes.object.isRequired,
          ;

          export default withStyles(styles)(HigherOrderComponent);





          share|improve this answer













          MaterialUI now includes CSS-in-JS docs functionality that will allow you to do just what you're asking.



          you probably want to do something like what they suggest and make use of their HOC API:



          import React from 'react';
          import PropTypes from 'prop-types';
          import withStyles from '@material-ui/styles';
          import Button from '@material-ui/core/Button';

          const styles =
          root:
          background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
          border: 0,
          borderRadius: 3,
          boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
          color: 'white',
          height: 48,
          padding: '0 30px',
          ,
          ;

          function HigherOrderComponent(props)
          const classes = props;
          return <Button className=classes.root>Higher-order component</Button>;


          HigherOrderComponent.propTypes =
          classes: PropTypes.object.isRequired,
          ;

          export default withStyles(styles)(HigherOrderComponent);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 23:27









          lazaruslaruelazaruslarue

          10912




          10912





















              0














              If you created application with npx create-react-app then



              1. Import your styles from *.module.css file. Example: import styles from './component.module.css' with content .ssss color: red

              2. Apply your style using styles.ssss. Example: <div className=styles.ssss>





              share|improve this answer



























                0














                If you created application with npx create-react-app then



                1. Import your styles from *.module.css file. Example: import styles from './component.module.css' with content .ssss color: red

                2. Apply your style using styles.ssss. Example: <div className=styles.ssss>





                share|improve this answer

























                  0












                  0








                  0







                  If you created application with npx create-react-app then



                  1. Import your styles from *.module.css file. Example: import styles from './component.module.css' with content .ssss color: red

                  2. Apply your style using styles.ssss. Example: <div className=styles.ssss>





                  share|improve this answer













                  If you created application with npx create-react-app then



                  1. Import your styles from *.module.css file. Example: import styles from './component.module.css' with content .ssss color: red

                  2. Apply your style using styles.ssss. Example: <div className=styles.ssss>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 31 at 15:05









                  ValeriyValeriy

                  7011933




                  7011933



























                      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%2f36336335%2freactjs-create-isolated-component-with-own-css%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

                      Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                      Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                      How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page