casesandberg / react-color

:art: Color Pickers from Sketch, Photoshop, Chrome, Github, Twitter & more
http://casesandberg.github.io/react-color/
MIT License
12.02k stars 917 forks source link

Add className in props #393

Closed searene closed 7 years ago

searene commented 7 years ago

Hi,

Could you add className to props of those react color components? So I can use them like this:

import React from 'react';
import { SketchPicker } from 'react-color';

class Component extends React.Component {

  render() {
    return <SketchPicker className="my-sketch-picker" />;
  }
}

Without it StyledComponents cannot work: https://github.com/styled-components/styled-components/issues/1086

And a custom className may also make the work much easier for a lot of people.

Thanks for considering it.

Regards, Searene

SpencerDawson commented 7 years ago

Unless I've misread here, ColorWrap passes all props it receives down to it's child, unless you are referring to each individual component inside, say, SketchPicker.

As per your remark on that issue, you could create your own Picker using the provided components and pass them className as needed, since each default picker provided is passed to colorWrap.

casesandberg commented 7 years ago

Yep, this makes a lot of sense to me! As Spencer pointed out, color wrap already passes it down, so all I had to do was set it on each of the pickers root divs!

casesandberg commented 7 years ago

Merged in https://github.com/casesandberg/react-color/pull/403