Skip to content
Components

Character counter

A ring that fills as a field nears its character limit.

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

<%= lc_field label: "Post", id: "my-component-post", class: "w-full max-w-md" do |field| %>
  <%= lc_textarea "Shipping a calmer sidebar today: it folds to icons and remembers your choice.", rows: 4, **field %>
  <div class="flex justify-end"><%= lc_char_counter max: 100, for: "my-component-post" %></div>
<% end %>
<%= lc_field label: "Post", id: "example-0-post", class: "w-full max-w-md" do |field| %>
  <%= lc_textarea "Shipping a calmer sidebar today: it folds to icons and remembers your choice.", rows: 4, **field %>
  <div class="flex justify-end"><%= lc_char_counter max: 100, for: "example-0-post" %></div>
<% end %>

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_char_counter

lc_char_counter(max:, for: nil, warn: 20, count: nil, **attributes)
InputDefaultValues
maxRequired—
fornil—
warn20—
countnil—
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults

The examples also use lc_field and lc_textarea. 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