Skip to content
Looking for every option?See the full API reference →

Boolean ​

The Boolean field renders a checkbox on form views and a green check or red X icon on the Index and Show views.

ruby
# app/avo/resources/post.rb
class Avo::Resources::Post < Avo::BaseResource
  def fields
    field :is_published, as: :boolean, name: "Published"
  end
end

Without additional options, forms use a checkbox, true and false values display their respective icons, and nil displays a dash.

An Avo index table with ID, Name and Published columns — a green check and a red X in the Published column.

Display a custom stored value as true ​

If your column stores "yes" rather than a Boolean, set true_value so it displays as checked. Avo also recognizes the strings "true" and "1" as true.

ruby
# app/avo/resources/post.rb
field :is_published, as: :boolean, true_value: "yes", false_value: "no"

Custom storage on forms

false_value does not define a separate false-value mapping for display. Present values that do not match a recognized true value display as false. Neither option changes the checkbox's submitted values: forms submit "1" when checked and "0" when unchecked. If your model stores custom values, handle that conversion in the model.

Make missing values more visible ​

If you want to distinguish an unset value from true or false at a glance, enable nil_as_indeterminate. On Index and Show views, nil then displays a gray minus-circle icon instead of a dash. This does not change the stored value or add a third checkbox state to forms.

ruby
# app/avo/resources/post.rb
field :is_published, as: :boolean, nil_as_indeterminate: true
Boolean field with nil_as_indeterminate showing a gray minus-circle icon

Use a toggle on forms ​

Enable as_toggle to style the checkbox as a toggle. It keeps the same checked and unchecked behavior and only changes the form's appearance.

ruby
# app/avo/resources/post.rb
field :is_published, as: :boolean, as_toggle: true

Options reference ​

See the Boolean API for all four field-specific options and their defaults. For options shared by fields, such as names, visibility, and help text, see Field options.