Input Fields
Input fields allow you to create input fields for your notes metadata and interact with them in live preview and reading mode. A bit like Obsidians properties UI, but not just at the top of your note.
Creating Input Fields
There are two ways of creating an input field in your note.
The first is using an inline code block, like this INPUT[inputType]
.
The second one is using a code block with meta-bind as the language, something like this.
Where inputType
is a valid input field type, like toggle
.
Binding to Metadata
Input fields can and should be bound to metadata fields, so properties in your frontmatter. This is achieved by adding the bind target behind the input type, separated by a colon.
In this example we will build a toggle that toggles the notes completion status by switching the completed
front-mater field between true
and false
.
First, we create a toggle.
Then we tell it to bind to the completed
frontmatter field using a Bind Target.
And our input field is working. The toggle will change the frontmatter and when the frontmatter changes, the toggle changes.
Of course you can utilize the full functionality of Bind Targets with input field. E.g. the following is possible.
Arguments
Some input types support arguments to further customize them. Arguments are specified in parentheses behind the input type.
Let’s say we want to create a dropdown select where you can choose between different ratings. For this we will use the inlineSelect
input field.
To add options to the dropdown select we will use the option(name)
argument.
Now we can see four options in the dropdown.
If we want numeric values to represent the rating in our frontmatter, we can pass two values to option(value, name)
.value
will be the value written to the frontmatter and name
will be the value displayed in the dropdown select.
We can also include commas in our value names by surrounding them with quotes.
Such strings also support escaping using a backslash. To have a single backslash in the name you can use a double backslash \\
.