Skip to content
Components

Toggle

Pressed controls, filter links and radio choices.

After the one-time setup, call the helper directly from ERB. No component import is needed.

<%= lc_inline role: "group", aria: { label: "Topics" } do %>
  <%= lc_toggle "Design", active: true %>
  <%= lc_toggle "Writing" %>
  <%= lc_toggle "Research" %>
<% end %>
<%= lc_inline role: "group", aria: { label: "Topics" } do %>
  <%= lc_toggle "Design", active: true %>
  <%= lc_toggle "Writing" %>
  <%= lc_toggle "Research" %>
<% end %>
<%= lc_inline do %>
  <%= lc_toggle "All projects", href: "/components/toggle.html", active: true, size: :sm %>
  <%= lc_toggle "Archived", href: "/components/badge.html", size: :sm %>
<% end %>
<%= lc_toggle "Unavailable", disabled: true %>
<%= lc_toggle "Add filter", ghost: true %>

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_toggle

lc_toggle(label = nil, active: false, ghost: false, size: :md, href: nil, name: nil, value: nil, input: {}, **attributes, &block)
InputDefaultValues
labelnilAccessible name, visible where applicable
activefalsetrue · false
ghostfalsetrue · false
size:md:sm · :md · :lg
hrefnil—
namenil—
valuenil—
input{}—
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured Rails ERB content

The examples also use lc_inline. 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.

API JSON · LLM reference