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

Preview ​

The Preview field adds an icon to each row on the Index view. Hover over it to see a popup with selected fields from that record, or click it to open the record's Show view.

ruby
# app/avo/resources/team.rb
class Avo::Resources::Team < Avo::BaseResource
  def fields
    field :preview, as: :preview
    field :name, as: :text, show_on: :preview
  end
end

By default, the preview column has a blank header and no fields are selected for the popup. Add show_on: :preview to each field you want to include.

Define the fields ​

The fields shown in the preview popup are configured similarly to how you configure the visibility in the different views.

Add show_on: :preview to include a field in the popup without changing its visibility in other views. Combine it with hide_on: :index when the value should appear in the popup but not as a table column.

ruby
# app/avo/resources/team.rb
class Avo::Resources::Team < Avo::BaseResource
  def fields
    field :preview, as: :preview
    field :name,
      as: :text,
      sortable: true,
      show_on: :preview
    field :color,
      as: Avo::Fields::ColorPickerField,
      hide_on: :index,
      show_on: :preview
    field :description,
      as: :textarea,
      show_on: :preview
  end
end
Record preview popover open over the Team index table, triggered from a row

Label the preview column ​

If you want a heading above the preview icons, set name on the preview field:

ruby
# app/avo/resources/team.rb
field :preview, as: :preview, name: "Preview"

Control who can preview records ​

The preview request authorization is controlled with the preview? policy method.

Reference ​

See the Preview API for the declaration, defaults, supported views, and value contract. Preview has no field-specific options. For shared field settings, see Common field options.