Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

p5.js | createSelect() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The createSelect() function in p5.js is used to create a dropdown menu element in the DOM (Document Object Model) for taking input. The .value() method is used to get the selected option. This function includes the p5.dom library. Add the following syntax in the head section.

Note: This function requires the p5.dom library. So add the following line in the head section of the index.html file.

<script src=””> 






  • multiple: It holds the state of input. Multiple if True, single if False.
  • existing: It holds the object DOM select element.

Return Value: This function returns the value of an attribute in p5.Element format.

Example: This example uses a dropdown menu to change the background color from the given options. 


// Create a variable for dropdown menu object
var dropdown;
function setup() {
    // Create a canvas
    // Create a dropdown menu object
    dropdown = createSelect();
    // Position the dropdown menu
    // Set options
function draw() {
    // Set the background-color as chosen
    // from the dropdown menu


  • Before changing the color:

  • During changing the color:

  • After changing the color:

Online editor: 
Environment Setup:


My Personal Notes arrow_drop_up
Last Updated : 03 Dec, 2021
Like Article
Save Article
Similar Reads
Related Tutorials