Toggle Field


The toggle field represents a true/false toggle. This field is typically used for boolean content values. You could use this to toggle a certain feature on the page on or off.

tinacms-toggle-field

Options

interface ToggleConfig extends FieldConfig{
  component: 'Toggle'
  name: string
  label?: string
  description?: string
}
OptionDescription
componentThe name of the plugin component. Always 'toggle'
nameThe path to some value in the data being edited.
labelA human readable label for the field. Defaults to the name. (Optional)
descriptionDescription that expands on the purpose of the field or prompts a specific action. (Optional)

This interfaces only shows the keys unique to the date field.

Visit the Field Config docs for a complete list of options.

Example: Published Flag

Below is an example of how a toggle field could be used to mark a blog post as published.

const BlogPostForm = {
  fields: [
    {
      name: 'published',
      component: 'toggle',
      label: 'Published',
      description: 'Check to mark this to publish the post.',
    },
    // ...
  ],
}