Skip to content
Components

Table of contents

An "On this page" list that marks the section the reader has scrolled to.

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

<%= lc_toc class: "w-full max-w-56" do |toc| %>
  <%= toc.link "Overview", "#overview" %>
  <%= toc.link "Usage", "#usage" %>
  <%= toc.link "Sizes", "#sizes", indent: true %>
  <%= toc.link "API reference", "#api" %>
<% end %>
<%= lc_toc class: "w-full max-w-56" do |toc| %>
  <%= toc.link "Overview", "#overview" %>
  <%= toc.link "Usage", "#usage" %>
  <%= toc.link "Sizes", "#sizes", indent: true %>
  <%= toc.link "API reference", "#api" %>
<% end %>

Getting started

Markdown renderers such as Kiln give every heading an id.

Install

The list and the links come from the same HTML.

<% article = capture do %>
  <h2 id="getting-started">Getting started</h2>
  <p>Markdown renderers such as Kiln give every heading an id.</p>
  <h3 id="install">Install</h3>
  <p>The list and the links come from the same HTML.</p>
<% end %>
<div class="flex w-full flex-col gap-section sm:flex-row-reverse sm:items-start">
  <%= lc_toc headings: article, class: "w-full sm:max-w-44" %>
  <%= lc_prose(anchors: true) { article } %>
</div>

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_toc

lc_toc(label: lc_t("lostcoords.ui.toc.label"), headings: nil, levels: 2..3, **attributes, &block)
InputDefaultValues
labellc_t("lostcoords.ui.toc.label")Accessible name, visible where applicable
headingsnil—
levels2..3—
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured Rails ERB content

lc_toc yields a builder, toc, with these parts. Each part carries data-slot and merges class: and native attributes.

InputDefaultValues
labelRequiredAccessible name, visible where applicable
urlRequired—
indentfalsetrue · false
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults

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