Sha256: 6af52214024b620b91ab223d0207fbb6b9c532ef599ccad6c988abbac46df82f

Contents?: true

Size: 908 Bytes

Versions: 127

Compression:

Stored size: 908 Bytes

Contents

---
title: "Groups and layouts"
label: "Groups and Layouts"
id: groups_layouts
---

By default, forms are oriented vertically. In other words, inputs are rendered from top to bottom in the order they are defined. Rendering inputs this way is generally more accessible than rendering inputs side-by-side, and should be preferred for most use-cases.

However in certain circumstances it may be appropriate to render groups of inputs horizontally, and Primer forms provides a grouping mechanism for doing so:

<%= code :ruby do %>
  class ExampleForm < ApplicationForm
    form do |example_form|
      example_form.group(layout: :horizontal) do |name_group|
        name_group.text_field(name: :first_name, label: "First name")
        name_group.text_field(name: :last_name, label: "Last name")
      end
    end
  end
<% end %>

The `layout:` argument also accepts a `:vertical` option, which is the default.

Version data entries

127 entries across 127 versions & 2 rubygems

Version Path
primer_view_components-0.35.2 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.49.1 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.49.0 previews/pages/forms/05_groups_layouts.md.erb
primer_view_components-0.35.1 previews/pages/forms/05_groups_layouts.md.erb
primer_view_components-0.35.0 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.48.2 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.48.1 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.48.0 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.47.1 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.47.0 previews/pages/forms/05_groups_layouts.md.erb
primer_view_components-0.34.0 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.46.1 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.46.0 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.45.0 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.44.3 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.44.2 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.44.1 previews/pages/forms/05_groups_layouts.md.erb
primer_view_components-0.33.0 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.44.0 previews/pages/forms/05_groups_layouts.md.erb
openproject-primer_view_components-0.43.1 previews/pages/forms/05_groups_layouts.md.erb