Components
Switch
An on or off setting that submits like a checkbox.
Usage
After the one-time setup, call the helper directly from ERB. No component import is needed.
<%= lc_stack gap: :related do %>
<%= lc_switch "Public project", name: "project[public]", checked: true %>
<%= lc_switch "Allow comments", name: "project[comments]", hint: "Members can comment on pages." %>
<% end %>
Examples
Switches
<%= lc_stack gap: :related do %>
<%= lc_switch "Public project", name: "project[public]", checked: true %>
<%= lc_switch "Allow comments", name: "project[comments]", hint: "Members can comment on pages." %>
<% end %>
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_switch
lc_switch(label, name: nil, value: "1", checked: false, unchecked_value: "0", hint: nil, **attributes)
| Input | Default | Values |
|---|---|---|
| label | Required | Accessible name, visible where applicable |
| name | nil | — |
| value | "1" | — |
| checked | false | true · false |
| unchecked_value | "0" | — |
| hint | nil | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
The examples also use lc_stack. 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.