Search code examples
javascriptp5.js

How to set multiple CSS style properties in p5.js?


I'm trying to make my input field have a black background and white text, but I can't find any documentation for the possible values input.style() can take. I'm currently trying:

input.style('background-color', "#121212", 'color', "#EEE")

The background color works, but the text color doesn't. I followed the same syntax the reference uses so I'm not sure why.

Also if anyone could point me to where in the documentation it lists all the possible arguments for .style() it'd be much appreciated.


Solution

  • The p5 style() function takes only two arguments: the property name and the value. You are trying to set additional properties by adding more arguments, which you cannot do. You need to break this up into two lines and set each property individually.

    input.style('background-color', "#121212")
    input.style('color', "#EEE")