rens
rens

Reputation: 45

(HTML/NextJS) Input Color Does Not Change When Declared Default Value

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 */
/>

Upvotes: 0

Views: 1063

Answers (1)

Mo_3
Mo_3

Reputation: 51

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

Upvotes: 2

Related Questions