Field
Labels, controls and validation that stay connected.
Usage
After the one-time setup, call the helper directly from ERB. No component import is needed.
<%= lc_field label: "Project name", id: "my-component-name", hint: "A short, memorable name.", class: "w-full max-w-sm" do |field| %>
<%= lc_input name: "project[name]", **field %>
<% end %>
Examples
Label and hint
<%= lc_field label: "Project name", id: "example-0-name", hint: "A short, memorable name.", class: "w-full max-w-sm" do |field| %>
<%= lc_input name: "project[name]", **field %>
<% end %>
Validation
<%= lc_field label: "Email address", id: "example-1-email", error: "Enter a valid email address.", class: "w-full max-w-sm" do |field| %>
<%= lc_input name: "email", type: :email, value: "alex@", **field %>
<% end %>
Rails forms
<%= form_with scope: :project, url: "#", class: "w-full max-w-sm" do |form| %>
<%= lc_field label: "Project name", id: form.field_id(:name), hint: "Works with Rails form builders." do |field| %>
<%= form.text_field :name, **field, class: lc_input_class %>
<% end %>
<% end %>
Form actions
<%= lc_inline class: "justify-end" do %>
<%= lc_button "Cancel", variant: :ghost %>
<%= lc_button "Save changes", type: :submit %>
<% end %>
Form builder
<%= lc_form_with model: DocsProject.invalid_example, url: "#", card: true, class: "w-full max-w-sm" do |form| %>
<%= form.field :name, hint: "Shown to members." %>
<%= form.field :email, as: :email_field, size: :sm, label: "Email (compact)" %>
<%= form.switch :public, hint: "Anyone with the link can view." %>
<%= form.submit "Save project" %>
<% end %>
Grouped controls
<%= lc_stack class: "w-full max-w-sm" do %>
<%= lc_fieldset legend: "Split", id: "example-5-split", hint: "Everyone pays the same share unless you change it." do %>
<%= lc_inline do %>
<%= lc_toggle "Equally", active: true %>
<%= lc_toggle "By amount" %>
<%= lc_toggle "By share" %>
<% end %>
<% end %>
<%= lc_stack gap: :related do %>
<%= lc_text "This app can", size: :label, tone: :muted %>
<ul class="m-0 ps-5 list-disc text-muted-foreground">
<li>Read your groups</li>
<li>Add expenses</li>
</ul>
<% end %>
<% end %>
File drop
<%= lc_file_drop name: "files[]", title: "Add receipts", hint: "PDF or images, up to 10 MB each", button: "Browse files",
accept: "image/*,application/pdf", multiple: true, class: "w-full max-w-md" %>
API reference
Helpers render semantic HTML and include their interaction wiring. Pass native attributes through class:, data:, aria: and the usual Rails options. Blocks use captured ERB content.
lc_field
lc_field(label:, id:, hint: nil, error: nil, size: :md, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| label | Required | Accessible name, visible where applicable |
| id | Required | — |
| hint | nil | — |
| error | nil | — |
| size | :md | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_fieldset
lc_fieldset(legend:, id: nil, hint: nil, error: nil, size: :md, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| legend | Required | — |
| id | nil | — |
| hint | nil | — |
| error | nil | — |
| size | :md | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_form_with
lc_form_with(card: false, padding: :md, gap: nil, **options, &block)
| Input | Default | Values |
|---|---|---|
| card | false | true · false |
| padding | :md | — |
| gap | nil | — |
| options | {} | — |
| block | Captured block | Captured Rails ERB content |
lc_file_drop
lc_file_drop(name: nil, title:, hint: nil, button: nil, icon: "arrow-up-tray", accept: nil, multiple: false, input: {}, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| name | nil | — |
| title | Required | — |
| hint | nil | — |
| button | nil | — |
| icon | "arrow-up-tray" | Heroicon name; spacing is handled automatically |
| accept | nil | — |
| multiple | false | true · false |
| input | {} | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
The examples also use lc_input, lc_inline, lc_button, lc_stack, lc_toggle, and lc_text. Each is documented on its own page.
Styling and extension
Use class: to merge utilities, native attributes for application behavior, and the theming guide for the shared palette. For custom markup, the advanced class helpers expose the same styles, including glass surfaces and class merging.