Fig Docs
  • 🏠Welcome to Fig
  • 👋Get Started
    • Download and Install
    • `fig home`
      • My Apps
      • The Sidebar
      • Settings
    • The Fig App Store
    • Hotkeys
  • 💪Autocomplete
  • 😀The Fig CLI
    • 1. Fig Overrides
    • 2. Fig Aliases
    • 3. $FIGPATH
    • 4. Fig Apps
  • 📖Interactive Runbooks
    • Form Elements
      • Input
      • Textarea
      • Dropdown
      • Checkboxes
      • Buttons
    • Templating & Interpolation
    • Scripting Language (Psilo)
      • Full List of Functions
    • Running Runbooks
    • Full Examples
  • ⚒️ Build your own CLI
    • `fig build`
    • .fig Files
  • 🧰Build your own App
    • Get Started
    • App Lifecycle
    • Key Concepts
      • Running Shell Commands
      • Reading Environment Variables
      • Accessing Files & Saving Data
      • Loading Local Resources
    • Window Managment
      • Setting Window Properties
      • Repositioning the Window
      • Focusing & Blurring the Window
    • Advanced
      • Creating a Pseudo-Terminal Session
  • Other
    • Fig for Teams
    • Security & Privacy
    • FAQ
    • Contact Us
  • Interactive Runbooks
Powered by GitBook
On this page
  • Important
  • Examples
  1. Interactive Runbooks
  2. Form Elements

Dropdown

PreviousTextareaNextCheckboxes

Last updated 4 years ago

^[id: placeholder ]{ array_of_options }

Important

You must pass options into the dropdown as an array. To create an array, you can split a string on commas (csv) or new lines (lines). You can also map over an array of objects (map ). You can learn more in Fig's e.g.

  • { "a,b,c" csv }

  • { "a\nb\nc" lines }

  • { [ ls ] sh lines}

    • Run the shell command ls

    • Parse the output by new lines

  • { [ aws ec2 describe-regions ] sh json "Regions" prop [ "RegionName" prop ] map }

    • run shell command aws ec2 describe-regions

    • JSON.parse the output

    • get the "Regions" property of the object (which is an array of objects)

    • Map over the array and create new array of the "RegionName" prop of each object

Examples

  • This is a big example. Look at the gif down the bottom

  • Specifically note the functions that between the curly braces. You can learn more in

  • Also note the "plans" object at the top (defined in data). This was used as a javascript element in the mustache braces at the bottom

```data
{
	"plans": {
		"hobby-dev": { "price" : 0},
		"hobby-basic": { "price" : 7},
		"standard-0": {"price": 50}

	}
	
}
```

<!-- NOTE: An array is a string that is split on commas using the csv function -->

Choose an animal
^[animal: Your chosen animal]{ "dog,cat,lizard" csv }
You chose **{{animal}}**  


Show IDs of all Docker Images
^[docker_image: abc_123 ]{ [ docker images -aq ] sh lines }
`docker run {{ docker_image }}`


Select AWS Region
aws ec2 describe-regions
^[aws_region: Region]{ [ aws ec2 describe-regions ] sh json "Regions" prop [ "RegionName" prop ] map }
You selected: **{{aws_region}}**


<!-- Loop through an array of JSON objects and get the name prop from each -->
Heroku App Name
^[app_name: dummy_name]{ [ heroku apps --json ] sh json [ "name" prop ] map }
{{ app_name }}


Add Postgresql to Heroku

^[plan: hobby-dev ]{ "hobby-dev,hobby-basic,standard-0" csv }

```
heroku addons:create heroku-postgresql:{{plan}}
```

**{{plan}}** costs **${{plans[plan].price}}**  per month.
📖
Scripting Language
Scripting Language