Etch doesn’t give you a UI for setting the default value of a select prop. The first option in the list is the default, so the only way to control it from the builder is to reorder your options and put the one you want first. That works, but it means your option order is decided by the default instead of by what makes sense to read. If you have a size prop with small, medium, large and you want medium to be the default, you either accept a jumbled list or accept the wrong default.

This script lets you have both. Drop an instance of the component onto any page or template open in Etch, then paste the script into the browser’s DevTools console and run it. Order doesn’t matter here, you can select the instance on the canvas first and then paste, or paste first and the script will wait until you select one. From there, a modal lists every select prop on the component, including nested ones inside group, repeater, and condition props. Pick a prop, pick a value from its options, and the new default is written to the component definition and saved right away. The script then double checks that the change stuck and lets you know either way.

A dropdown menu titled "headingLevel — choose a new default" utilizes the Select Prop of the Etch Component, offering options for h1, h2, and h3. Instructions to click or type a number are shown below.

Note: The script won’t run while you’re in Component Edit Mode. Exit the editor first, then run it against an instance on the canvas.

JavaScript