Sub topic 6
Form elements: markdown, input, textarea, dropdown, checkboxes
This chapter assumes you know the basic issue form structure from the previous chapter: a YAML file in .github/ISSUE_TEMPLATE/ with top-level keys such as name, description, and a body list. It also assumes you can read YAML lists and nested keys. Here you will learn what each of the five element types does and which attributes it accepts.
How elements fit together
The body key holds a list. Each item is one element, and each element has a type. GitHub renders the elements in order, from top to bottom. Most elements also take an attributes map. Elements that collect input take an optional id, which names the field in the submitted issue and in URL prefills.
Only one element is display-only. The other four collect input from the person filing the issue.
| Type | Collects input? | Typical use |
|---|---|---|
| `markdown` | No | Instructions, warnings, links |
| `input` | Yes, one line | Version number, URL |
| `textarea` | Yes, multiple lines | Steps to reproduce, logs |
| `dropdown` | Yes, pick from a list | Operating system, severity |
| `checkboxes` | Yes, tick boxes | Confirmations, acknowledgements |
The five elements in one form
The following form uses every element type.
name: Bug report
description: Report something that is not working
title: "[Bug]: "
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report a bug.
- type: input
id: version
attributes:
label: Version
description: Which version are you running?
placeholder: "1.4.2"
validations:
required: true
- type: dropdown
id: os
attributes:
label: Operating system
options:
- Windows
- macOS
- Linux
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
description: List the steps needed to see the problem.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
render: shell
- type: checkboxes
id: terms
attributes:
label: Before submitting
options:
- label: I searched existing issues for duplicates
required: trueElement by element
markdown
The markdown element shows text and produces no output in the issue. Put the text in attributes.value. Use it for instructions, such as a reminder not to paste secrets. It cannot have an id or validations.
input
The input element is a single-line text box. Its label is required. Use description for help text under the label and placeholder for a greyed-out example inside the box. Use value to set pre-filled text. Choose input for short answers such as a version number.
textarea
The textarea element is a multi-line box that accepts Markdown. It takes the same label, description, placeholder, and value attributes as input. It also takes render. When you set render: shell, GitHub wraps the submitted text in a code block with that language. The reporter does not need to add backticks. Because of this, the field no longer renders Markdown and a shell block is easier to read.
dropdown
The dropdown element lets the reporter pick from options, a list of strings. Add multiple: true to allow more than one choice. In the 1.x versions of the schema, you can also set default to the zero-based index of the option selected at the start. Keep each option unique, because duplicates are rejected.
checkboxes
The checkboxes element shows a group of boxes. Each entry in options is a map with a label, and an optional required: true. A required box must be ticked before the form can be submitted. Use this for confirmations, not for questions, because the issue only records ticked or unticked.
Common errors
- A form with no
labelon an element is invalid, and GitHub does not show the template. - Reusing an
idin two elements is invalid. IDs may contain only letters, numbers,-, and_. - Writing the
requiredkey underattributesinstead ofvalidationshas no effect. The next chapter covers validations in detail. - Putting a plain string in
checkboxesoptionsfails. Each option needs alabelkey.
Exercise
You want a form field where the reporter picks one of "Low", "Medium", or "High" severity, and a second field where they paste a stack trace that appears as a code block. Which two element types do you use, and which attribute makes the second one a code block?
Show answer
Use a dropdown with options for the severity, and a textarea with render set to a language such as shell for the stack trace. The render attribute wraps the submitted text in a code block.