Comments (7)
I have added TextFieldProps={{ value: color }} to the props in order to make it work.
from material-ui-color-picker.
Same here on my end. Component looks like this:
<ColorPicker
name="primaryColor"
value={primaryColor}
// defaultValue="#000"
onChange={(color: any): void => {
setPrimaryColor(color);
}}
/>
With defaultValue the input is set and the color of the value is changing, but the value is not changing. Without defaultValue the input is empty and not changing.
That makes the component useless for me.
from material-ui-color-picker.
Thanks, @vorvex! I think we need to improve the documentation with some new examples to clarify its usage.
As mentioned in the main description, this component is based in the material-ui TextField component. You can add many other props to improve component behavior and presentation.
In my case, I used a controlled component to show even an icon inside:
<ColorPicker
id="new-reminder-color"
name='color'
value={this.state.color}
onChange={color => this.handleColorChange(color)}
TextFieldProps={{
value: this.state.color,
variant: "outlined",
className: classes.formInput,
label: "Reminder Color",
helperText: "Tag your reminder with a color"
}}
InputLabelProps={{
shrink: true,
}}
InputProps={{
endAdornment:
<InputAdornment position="end">
<Icon className="fas fa-tag" style={{ color: this.state.color }} />
</InputAdornment>,
}}
/>
In this example, you have to import the InputAdornment and Icon components form material-ui
from material-ui-color-picker.
@bitcod3r why you have TextFieldProps
? It doesn't work for me. I need to set value on IputProps
<ColorPicker
label={label}
variant="outlined"
value={value}
onChange={onChange}
InputProps={{ value: value }}
/>
from material-ui-color-picker.
This package (https://viclafouch.github.io/mui-color-input/) handles this problem, supports both React 17 / 18 and MUI V5
from material-ui-color-picker.
I have the same thing =(
from material-ui-color-picker.
Hey guys! I am using inputRef to display color value
.....
const colorRef = useRef(null);
.....
<ColorPicker
label={label}
variant="outlined"
inputRef={colorRef}
value={value}
onChange={(color) => onChange(color); ((colorRef?.current) as any).value = color}
/>
from material-ui-color-picker.
Related Issues (20)
- Upgrade to material-ui v1 HOT 1
- The PickerDialog disappears when scrolling if the ColorPicker is contained in an element with a scroll bar HOT 4
- how to set value of the colorpicker later on state update? HOT 3
- Color Picker should position above the Textfield when there is no space at bottom HOT 1
- Installation error HOT 1
- UI suggestions HOT 1
- onChange handlers get mixed up when using multiple instances HOT 1
- Types package
- Add a Button Option for Color Picker HOT 1
- Missing decoration file
- Deprecation warning for React.createFactory()
- Some Actions
- Set and clear value from ColorPicker Textfield HOT 1
- Denial of Service vulnerability caused by node-fetch
- Color Picker JSS styles are using the same class name as elements already on my page
- Is this project still alive ? HOT 1
- a vulnerability CVE-2020-15168 is introduced in material-ui-color-picker
- When I am changing the color from palette hex code is not getting updated the input field I am using functional component HOT 4
- Library needs to be updated to reflect @mui import HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-ui-color-picker.