Home > Software engineering >  (HTML/NextJS) Input Color Does Not Change When Declared Default Value
(HTML/NextJS) Input Color Does Not Change When Declared Default Value

Time:02-02

My color input appears not working/changing when declared default value (#ffffff)

enter image description here

But if I don't declare it, it works normally.

enter image description here

Keep in mind that I am on a NextJS framework.

<input
    type='color'
    className={styles['change-bg']} /* Some css */
    value="#ffffff" /* the default value */
/>

CodePudding user response:

Instead of value attribute use defaultValue, this will solve your problem.

The following blog is from react and refer to this link for the reason: https://reactjs.org/docs/uncontrolled-components.html#default-values

  •  Tags:  
  • Related