Boolean inputs

Last modified: September 11th, 2024

A Boolean input lets your team add true or false values to your data files or front matter.

There are two types of Boolean input:

  • Checkbox
  • Switch

Boolean inputs are simple. Beyond configuring the type (Checkbox or Switch) and the general configuration options available for all inputs, there are no more configuration keys.

Checkbox#

The Checkbox Boolean input provides an editing interface for true or false values. True values have a checked box, while false values have an unchecked box.

A screenshot of two Checkbox Boolean inputs in the Data Editor, showing one true and one false value.

You can configure a Checkbox input using the type key with the value checkbox. Define the type key under your input key name within _inputs. For more information, please read our documentation on configuring your inputs.

cloudcannon.config.yaml
copied
_inputs:
  blog_published:
    type: checkbox

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

This Boolean input is called blog_published.

The value of the type key determines the input type. This is a checkbox Boolean input.

cloudcannon.config.json
copied
{
  "_inputs": {
    "blog_published": {
      "type": "checkbox"
    }
  }
}

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

This Boolean input is called blog_published.

The value of the type key determines the input type. This is a checkbox Boolean input.

Once configured, the Checkbox Boolean input will appear in the Data Editor or the Visual or Content Editor sidebar when you add it to a data file or the front matter of a markup file.

blog.md
copied
---
blog_published: true
---

Blog content goes here.

Switch#

The Switch Boolean input provides an editing interface for true or false values. True values show the switch to the right with the text "ON", while false values show the switch to the left with the text "OFF".

A screenshot of two Switch Boolean inputs in the Data Editor, showing one true and one false value.

You can configure a Switch input using the type key with the value switch. Define the type key under your input key name within _inputs. For more information, please read our documentation on configuring your inputs.

cloudcannon.config.yaml
copied
_inputs:
  featured:
    type: switch

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

This Boolean input is called featured.

The value of the type key determines the input type. This is a switch Boolean input.

cloudcannon.config.json
copied
{
  "_inputs": {
    "featured": {
      "type": "switch"
    }
  }
}

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

This Boolean input is called featured.

The value of the type key determines the input type. This is a switch Boolean input.

Once configured, the Switch Boolean input will appear in the Data Editor or sidebar of the Visual or Content Editor when you add it to a data file or the front matter of a markup file.

data.yml
copied
featured: false

Unconfigured Boolean inputs#

In some cases, CloudCannon can still detect a Boolean input even if you have not configured it.

CloudCannon will interpret any unconfigured input with a true or false value as a Checkbox Boolean input. CloudCannon cannot create a Switch input without configuration.

article.md
copied
---
public: true
---

Content goes here.

This behavior is convenient if you have simple inputs or do not want to configure inputs. It is also beneficial for new websites on CloudCannon where you have yet to create any CloudCannon-specific configuration.

We recommend configuring your inputs for greater control over their functionality and appearance.

Valid values#

Here are some examples of valid values for the key is_true. These work for both Checkbox and Switch inputs.

Empty/null value:

  • is_true:

Boolean values (without any quotation marks):

  • is_true: true
  • is_true: false

Boolean values (without any quotation marks):

  • is_true = true
  • is_true = false

Null value:

  • "is_true": null

Boolean values (without any quotation marks):

  • "is_true": true
  • "is_true": false

Related Articles

Open in a new tab