# Update options of dropdown menu

**URL:** <https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030>\
**Category:** Questions\
**Tags:** lil-gui\
**Created:** [October 28, 2026, 3:49pm UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030 "2026-10-28T15:49:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SimRuJ](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@SimRuJ](https://discourse.threejs.org/u/SimRuJ)\
**Post date:** [October 28, 2026, 3:49pm UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030/1 "2026-10-28T15:49:31Z")

</div>

I created the following menu in r184:

```javascript
let folder = gui.addFolder("A Folder");

const props = {
    "text field": "",
    "dropdown": 0,
    "slider": 0.5
};

let textfield = folder.add(props,"text field");
let dropdown = folder.add(props,"dropdown",[0]).onChange(val => { selectNumber(val) });
let slider = folder.add(props,"slider",0,1,0.1);

```

Later I want to add more options to the dropdown (e.g. [0,1,2]) but keep it as menu item 2.

According to the docs for the `options` function ([link](https://lil-gui.georgealways.com/#Controller#options)), you should be able to do that with the following, as long as the original controller is already a dropdown:

```
folder.add(props,"dropdown",[0,1,2]);

```

But this adds a forth menu item called “dropdown” at the end (with the options 0, 1 and 2). The originals still only has 0.

I also tried the following, which updated the controller but also moved it to the end:

```
dropdown.options([0,1,2]);

```

How do I update the controller without moving it or creating a duplicate?

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/75911_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [October 29, 2026, 12:50am UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030/2 "2026-10-29T00:50:25Z")

</div>

The controller moving to the end is a bug/feature of lil-gui.  
Try the OG dat.gui

> **[Appending to a dropdown in lil-gui or dat.gui](https://editor.sbcode.net/c65bf2c45db35b3ae180cec261e24f90114b0e90)**
>
> different behaviours

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [October 29, 2026, 6:53am UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030/3 "2026-10-29T06:53:36Z")

</div>

Managed to do it with lil-gui by inserting the options directly in its internal structure. I’m not sure whether there are some side effects, especially lost event listeners and other hooks.

```javascript
function addOptions( obj, values ) {
    values.forEach( value => {
        obj.$select.add( new Option(value) );
        obj._values.push( value );
    }); // forEach
} // addOptions

addOptions( dropdown, [4, 5, 6, 7, 8] );

```

Demo: [https://editor.sbcode.net/df3e7dd111c33e259c24dc1367672d8a436d4115](https://editor.sbcode.net/df3e7dd111c33e259c24dc1367672d8a436d4115)

---

<div class="post-metadata">

**Author:** ![SimRuJ](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@SimRuJ](https://discourse.threejs.org/u/SimRuJ)\
**Post date:** [October 29, 2026, 9:16am UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030/4 "2026-10-29T09:16:06Z")

</div>

No idea what version is included in Three.js r184 but the [issue](https://github.com/georgealways/lil-gui/issues/86#issuecomment-1783140863) about it on github says that this shouldn’t happen. Does this mean that it’s a new bug or is anything missing?  
Do you have to add `onChange` every time you change the options?

I thought dat.gui is outdated and shouldn’t be used anymore?

---

<div class="post-metadata">

**Author:** ![SimRuJ](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@SimRuJ](https://discourse.threejs.org/u/SimRuJ)\
**Post date:** [October 29, 2026, 10:02am UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030/5 "2026-10-29T10:02:57Z")

</div>

Thanks! I did a little bit of testing and `onChange` still works as expected.

A short explanation for the code:

`add` adds the actual list item to the dropdown.  
`push` adds its value.

E.g. If you only `add` the number 2 but don’t `push` it, then “2” will still be in the dropdown but if you select it, then it’ll turn into “undefined” and the `onChange` function will also return “undefined”.  
The order you add items in is important! If you add “1” and “2” but push “2” and “1”, then “1” will turn into “2” (and vice versa) if you select it. You also can’t push an array, `push([1,2])` turns into “1,2” in the list and `onChange`.

You can also remove an element from the dropdown with:

```javascript
dropdown.$select.remove(0);
//dropdown._values.shift(); //removes the first element
dropdown._values.splice(0,1); //removes one element starting at index 0

```

The element isn’t in the list anymore if I click on the dropdown but it still appears as the default selected element while the dropdown is closed, until I select another one. `$select` seems to be a `HTMLSelectElement` and `dropdown.$select.value` correctly changes from “0” to “1” if “0” is removed (actual value, not index!) but I haven’t found a way to remove the last remnants of this 0th element yet (=change this wrong “label”). Any idea?

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/75911_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [October 29, 2026, 11:03am UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030/6 "2026-10-29T11:03:18Z")

</div>

> [@SimRuJ](#):
>
> the [issue](https://github.com/georgealways/lil-gui/issues/86#issuecomment-1783140863) about it on github says that this shouldn’t happen

Threejs includes the older version `lil-gui v0.17`

> <https://github.com/mrdoob/three.js/blob/master/examples/jsm/libs/lil-gui.module.min.js#L4>

So here is an example using latest `lil-gui@0.21`

> **[Appending to a dropdown in lil-gui@0.21](https://editor.sbcode.net/273233aab12cd753bea48407da495a33390cf539)**
>
> https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [October 29, 2026, 11:07am UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030/7 "2026-10-29T11:07:10Z")

</div>

> [@SimRuJ](#):
>
> but I haven’t found a way to remove the last remnants of this 0th element yet (=change this wrong “label”). Any idea?

If you need to use the old version, you can put any value when you remove the currently selected value:

```js
dropdown.$select.selectedIndex = -1;
dropdown.$display.innerHTML = 'hoho';

```

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/c/e/ce4175aa4cb9925872ee6cd2c79c98cac76c34f1.png)

But, yet, it is much better to use the new library, as @seanwasere pointed out.

---

<div class="post-metadata">

**Author:** ![SimRuJ](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@SimRuJ](https://discourse.threejs.org/u/SimRuJ)\
**Post date:** [October 30, 2026, 9:41am UTC](https://discourse.threejs.org/t/update-options-of-dropdown-menu/96030/8 "2026-10-30T09:41:46Z")

</div>

@PavelBoytchev  
Thanks, `dropdown.$display.innerHTML = dropdown.$select.value`did it!  
No need to changed the `selectedIndex`, it automatically selects another one, as long as there’s still one element left (`if(index<dropdown._values.length && dropdown._values.length>1)`). At least, if I delete the very first one, it automatically selects the second=new first element.

@seanwasere  
Ah, that explains it, thanks!  
I currently can’t update anything, so I have to use the HTML version. Do you know if there are any plans to update lil-gui to the latest version in a future Three.js version?
