Default

1
<%= render SelectComponent.new(
2
      name: "country",
3
      placeholder: "Select a country",
4
      options: [["United Kingdom", "uk"], ["United States", "us"], ["Germany", "de"], ["France", "fr"]]
5
    ) %>

Disabled

1
<%= render SelectComponent.new(
2
      name: "country",
3
      placeholder: "Disabled",
4
      options: [["United Kingdom", "uk"], ["United States", "us"]],
5
      disabled: true
6
    ) %>

In field set

Used for billing and shipping.

1
<%= render FieldSetComponent.new do |f| %>
2
  <% f.with_label(text: "Country", for: "country") %>
3
  <% f.with_field do %>
4
    <%= render SelectComponent.new(name: "country", id: "country", placeholder: "Choose…",
5
          options: [["United Kingdom", "uk"], ["United States", "us"]]) %>
6
  <% end %>
7
  <% f.with_helptext { "Used for billing and shipping." } %>
8
<% end %>

With value

1
<%= render SelectComponent.new(
2
      name: "country",
3
      value: "us",
4
      options: [["United Kingdom", "uk"], ["United States", "us"], ["Germany", "de"], ["France", "fr"]]
5
    ) %>