Skip to content
lostcoordsPublic

About

Lost Coordinates UI: Rails engine with Tailwind class builders, Hotwire overlays and a component showcase

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

lostcoords-ui

Render complete UI components from Rails views. Helpers include semantic HTML, accessible attributes and Stimulus wiring. Tailwind v4 supplies the styles. The Rails engine integrates Propshaft, importmap and tailwindcss-rails.

<%= lc_button "Save changes", type: :submit, icon: "check" %>
<%= lc_button_link_to "Projects", projects_path, variant: :secondary %>

<%= lc_card do %>
  <%= lc_field label: "Project name", id: "project-name" do |field| %>
    <%= lc_input name: "project[name]", **field %>
  <% end %>
<% end %>

The supported stack is Rails 8 or later with ERB, Tailwind and Stimulus. Each host application's lockfile pins its gem version, so publishing a library update does not upgrade consumers.

Install

gem "lostcoords-ui", "~> 0.14.0"

The engine adds its rendering helpers to host views, its views and translations to the host's lookup paths, its JavaScript to the asset paths and its pins to the importmap. Translations live under lostcoords.ui.*; a host locale file overrides any of them.

Stylesheets

Import the engine's stylesheet after your Tailwind imports. tailwindcss-rails generates this path from the installed gem on every build:

/* app/assets/tailwind/application.css */
@import "../builds/tailwind/lostcoords_ui.css";

Tailwind always ships component rules, used or not, and generates every utility the scanned helpers mention. For a smaller build, import core.css and the opt-in components you render instead of everything. Each entry carries the rules and scans the sources of its own component only. Every Tailwind build writes stable paths for them next to the engine's own import:

/* app/assets/tailwind/application.css, instead of ../builds/tailwind/lostcoords_ui.css */
@import "../builds/tailwind/lostcoords_ui/base.css";
@import "../builds/tailwind/lostcoords_ui/core.css";
@import "../builds/tailwind/lostcoords_ui/components/dialog.css";
@import "../builds/tailwind/lostcoords_ui/components/menu.css";

base.css holds the document defaults: body styles, heading defaults, global inline-code styles, the focus ring and the reduced-motion reset. Skip it when the host owns its base styles, map the library's tokens to your app's theme and keep your Tailwind theme declarations after the imports. core.css holds the tokens, buttons, badges, avatars, cards, alerts, form controls, choices, toggles, layout, typography and navigation. The opt-in entries are dialog (with the phone sheet), menu (menus and popovers), toast, search, tooltip, hovercard, collapsible, code-block, emoji-picker (its phone sheet also needs dialog), table, prose and shell (lc_app_header, lc_sidebar, lc_docs_shell and lc_dock; the dock's action menu and the sidebar's account menu also need menu). A component whose entry is missing renders unstyled.

The gem's stylesheets write into the components and modules layers, so the host declares that layer order. The theme defines the dark: variant with html[data-theme="dark"], and with html[data-theme="system"] under an OS dark preference. Each entry carries its own @source lines, so Tailwind scans the gem's helpers, views and JavaScript wherever the gem is installed.

Theming

Colors use shadcn/ui names, so a shadcn or tweakcn theme drops in. Set data-theme="dark" on <html> for dark mode, or data-theme="system" to follow the OS with no pre-paint script, which keeps cached HTML theme-agnostic. Your app owns the switch and saved preference. A dark override written for html[data-theme="dark"] does not reach system: use light-dark() for colors, or repeat it under @media (prefers-color-scheme: dark). Override any of these after the engine import:

:root {
  --primary: oklch(46% 0.14 155);
  --radius: 0.625rem;      /* every corner scales from this */
  --lc-density: 0.875;     /* semantic spacing and control heights */
}

html[data-theme="dark"] {
  --primary: oklch(75% 0.14 155);
}
Setting Default Drives
--background --foreground white, near black page and body text
--card --card-foreground light gray cards
--card-input --card-secondary --input, --secondary fields and secondary buttons inside cards and list rows; set them when --card matches either fill
--popover --popover-foreground page background menus, popovers, dialogs
--primary --primary-foreground near black, white primary actions, links, selection, focus
--secondary --secondary-foreground gray secondary buttons
--muted --muted-foreground light gray, mid gray subtle fills; secondary text, hints, placeholders
--accent --accent-foreground gray hovered rows and menu items, inline code
--destructive --success --warning status; soft fills such as bg-success-soft are generated
--border --input --ring dividers, input fills, focus ring
--radius 0.5rem rounded-sm to rounded-3xl and rounded-pill; the default keeps Tailwind's own sizes
--lc-density 1 the semantic spacing and control heights below
--lc-inset 1.25rem padding of cards, dialogs and popovers
--font-sans --font-display --font-mono system font families
--font-eyebrow var(--font-mono) eyebrow text; Japanese eyebrows use --font-sans

Defaults live in app/assets/tailwind/lostcoords/ui/theme.css. Lostcoords::Ui::TOKENS lists the public colors and fonts. Library-internal settings use the --lc- prefix.

Foundations

Components never set outer margin. Layout helpers own the space between things, and components pad themselves from --lc-inset. Every token is a Tailwind utility:

Spacing Default Use
tight 4px icon and label
related 8px label and control, button groups
heading 12px a heading and its content
content 16px blocks and fields
inset --lc-inset container padding and the gaps between its blocks
section 32px sections on a page

Use them as gap-related, p-inset, py-section and so on. Setting --lc-inset on an element changes the padding of every card or dialog inside it.

Type role Size / line height Use
text-display 36 / 40px, bold hero
text-title 30 / 36px, bold page title
text-heading 20 / 28px, bold section title
text-subheading 18 / 24px, semibold card and dialog titles
text-body 16 / 24px text
text-small 14 / 20px hints and secondary text
text-label 14 / 20px, medium labels, buttons, menu items
text-caption 12 / 16px metadata, table headers
text-eyebrow 12 / 16px, medium, uppercase kickers and column labels

Each role sets size, line height, tracking and weight together. lc-trim trims the space above the capital letters and below the baseline where the browser supports text-box.

Buttons, inputs, selects, toggles and icon buttons share heights: h-control-sm (32px), h-control-md (40px) and h-control-lg (48px). On touch screens the small and medium sizes grow to at least 40 and 44px. Containers use max-w-page, max-w-reading and max-w-form, and the page container pads with px-gutter.

Importmap

The engine pins its modules under lostcoords/ui/*. Controllers are also pinned under the host's controllers/* key with an lc_ prefix, so Rails' controller loading registers them as lc-dialog, lc-menu, lc-copy and so on. Load them lazily, so a page downloads only the controllers it uses, the first time their data-controller appears:

// app/javascript/controllers/index.js
import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
import { application } from "controllers/application"

lazyLoadControllersFrom("controllers", application)

eagerLoadControllersFrom also works and downloads all of them on every page. A host file with the same name, such as app/javascript/controllers/lc_dialog_controller.js, replaces the gem's.

To register controllers by hand instead, import registerControllers from the lostcoords/ui pin:

import { registerControllers } from "lostcoords/ui"

registerControllers(application, { only: ["lc-copy", "lc-collapsible"] })

Omit only to register every library controller. Unknown identifiers raise before anything is registered, and repeated calls on the same application keep later overrides, so register defaults before application overrides.

Changes in 0.14.14

Nothing needs an edit; a host that waits on a dialog's animations after close() before clearing up can use closeDialog instead. Added:

  • closeDialog(dialog) in lostcoords/ui/helpers/dialog closes a dialog and settles once it has left. In Safari close() now returns while the dialog is still open for its exit, so code that checked dialog.open after its animations could find it open.
  • The lc-light-dismiss controller comes with every popover: true or popover: "auto" an lc builder renders. It closes the popover itself on a tap outside, Escape or a popovertarget hide, with its exit: Safari dropped a native popover in the frame the browser closed it.
  • data-lc-popover-close on a link or button inside such a popover closes it, with its exit, so an in-page link in a menu needs no controller of its own.
  • hidePopoverAfterExit(popover) in lostcoords/ui/helpers/top_layer hides a popover from your code with its exit.

Changes in 0.14.13

Nothing needs an edit. Fixed:

  • Overlays animate out in Safari. WebKit can't transition overlay or display, so a closing dialog, phone sheet, menu, popover or tooltip left the screen in the frame it closed; a sheet released halfway down vanished mid-slide. lc-sheet now holds a closing dialog in its exit pose ([data-closing]) until the slide or fade ends, whether close(), Escape, the backdrop, a swipe or a method="dialog" form closed it, and a lifted panel stays in the top layer, shown as it was, until its exit ends. Chrome keeps its native exit. Where the exit is held, close fires when it ends; lc-sheet:exit fires as it starts, and the confirm sheet answers then.
  • A sheet held still before lifting settles back. It kept the finger's speed from before the pause, so a slow drag, a pause and a lift could dismiss it.
  • A released sheet carries on at the finger's speed, shortening its slide (to 240ms at least) instead of always taking the full 500ms.

Changes in 0.14.12

Needs an edit only if you import component entries one by one: emoji-picker now also needs dialog, which holds the phone sheet. Changed:

  • The emoji picker's phone sheet is the shared lc-sheet. It had its own copy with tighter corners, a darker backdrop and a faster slide; it now has the radius, scrim and timing of every other sheet.
  • lc_list_field rows are inset like the rows around them from sm up (px-inset); they sat 4px further out than lc_list_row and the section heading.
  • lc_icon_button_class defaults to shape: :circle, as lc_icon_button does, so the compact pager's arrows are round. Pass shape: :square to keep the old look.
  • The responsive nav's links and indicator are squircles from sm up, like layout: :row. Being pills on phones had switched the squircle off at every width.
  • Popovers, hovercards and the emoji popover take their timing from --lc-motion-feedback; they wrote the same 160ms as a literal.

Fixed:

  • An avatar in an lc_avatar_stack shows the focus ring. The stack removed every avatar's outline, including the ring of one rendered as a button.

Changes in 0.14.11

Nothing needs an edit. Changed:

  • A disabled lc_input, lc_select, lc_textarea or toggle pill looks disabled: muted text and a not-allowed cursor, as buttons and segmented items already had. A disabled select no longer fills on hover.
  • Emoji grid buttons show the focus ring. They marked keyboard focus with the hover fill alone.
  • The emoji picker has a set height, on desktop and as a phone sheet. It grew when its catalog arrived after opening, and on desktop could jump to the other side of its trigger.
  • lc_search group titles use the eyebrow role, so under lang="ja" they drop the mono face and uppercase like every other eyebrow.

Fixed:

  • Input methods. Escape that cancels a conversion no longer closes the dialog, menu or popover around the field. lc_search shows results for text committed from an input method in Chrome, which sends no input event after the composition ends. In Safari, the Enter that commits a conversion no longer picks the first match in the emoji picker or any other catalog picker.
  • A catalog that failed to load is asked for again on the next open; the failure was kept until a full page load.
  • An lc_dialog replaced while open releases the page. A stream that swapped the open dialog sent no close event, so the page stayed scroll-locked.
  • A linked or interactive card eases its lift and fill on hover. The transition named transform, which the lift does not use, and replaced the card's own.
  • A button-mode lc_toggle_group renders its value: selected. The choice appeared only once the controller connected.
  • An lc_fieldset with an error turns its legend red, as a field does its label.
  • Skin-tone options carry aria-checked, so a screen reader announces the chosen one.
  • lc_char_counter follows a form reset, and a tooltip dismissed with Escape shows again after coming back to a cached page.
  • A collapsible closes in a browser without ::details-content, where reading its duration threw.

Changes in 0.14.10

Nothing needs an edit. Added:

  • Pills can scroll in one row. lc_toggle_group(variant: :pills, scroll: true) keeps its pills in a single row that scrolls sideways, its edges fading while there is more to see; scroll: :narrow does so only while the nearest @container is under @md, and wraps above it. A pill's focus ring stays visible at the scroller's edge.

Changes in 0.14.8

Nothing needs an edit. Changed:

  • An lc_list_field row rings while its plain input has focus. It showed the accent fill alone, so these rows were the one place a focused field had no ring. The fill stays.

Fixed:

  • A lifted panel moves in the frame it grows in. A panel that outgrew the viewport as its content loaded, such as the emoji picker when its catalog arrives, was painted once at the old spot before flipping to the other side of its trigger.

Changes in 0.14.7

Nothing needs an edit. Fixed:

  • Focus also returns when the host removes the dialog as it closes. Such a caller unregisters before the close event arrives, which is where 0.14.6 returned focus, so Safari still left it on the page. Focus now settles when a closed dialog is unregistered.

Changes in 0.14.6

Nothing needs an edit. Fixed:

  • Focus returns to the pressed control in Safari. Safari on a Mac doesn't focus a button or link on click, so the browser had nothing to hand focus back to when a dialog closed and it fell to the page. registerDialog now remembers what was pressed and returns focus there when closing leaves it nowhere.
  • showContextDialog opens through showDialog, so a dialog anchored to a menu takes focus itself, as every other dialog does, instead of ringing its first control. The confirm sheet no longer repeats the step.

Changes in 0.14.5

One edit, only for a host that skips base.css:

  • The focus ring is drawn in one place, lc-focus-ring. Fields and the emoji picker's search drew their own copy as a box shadow, and a linked list row drew a third with a different offset. They now take the shared ring: base.css applies it to whatever holds keyboard focus, and the list row applies the same utility while its link has focus. A host with its own base styles gets its own focus style on fields; to keep the library's, add :is(input, textarea, select):focus-visible { @apply lc-focus-ring; }.

Faster:

  • The emoji catalog loads when someone reaches for the picker (pointer, touch or focus), not with every page that has one. It is every emoji there is, about 900KB of markup; opening the picker waits for the same request.

Changes in 0.14.4

Nothing needs an edit. Focus behaves more like the platform:

  • Returned focus shows its ring only for keyboard users. Browsers ring whatever is focused after a key press, and Escape, Enter in a field and typing are key presses, so a dialog opened with the mouse and closed with Escape left a ring on its button. Focus that comes back from a closed dialog, sheet, menu, popover or search now shows the ring only after Tab or an arrow key moved focus. A controller that moves focus back itself calls the new settleFocus() from lostcoords/ui/helpers/focus.
  • A panel closed from inside returns focus to what opened it. Choosing a menu item or an emoji left focus on a hidden element, so it fell to the page.
  • The emoji picker's search halo reads --ring like every other field, not a --focus-halo variable the library never defined.

Changes in 0.14.3

Nothing needs an edit, and one look changes:

  • An unchecked switch has a visible track on any surface. It drew its track with --input, so on a host whose cards share the field fill it showed only its thumb. The track is now --lc-switch-track, a translucent foreground tint that shows on the page, a card or any other fill, in both themes. Set it to restyle the track; checked switches still fill with --primary.

Changes in 0.14.2

Nothing needs an edit unless you override the disabled look, and one look changes:

  • A disabled control marked aria-busy="true" keeps its enabled look. It still can't be pressed and gives no hover or press feedback; only its cursor, progress, tells. Render a control that waits for its script this way and it no longer flashes grey for the moment before the script turns it on. Buttons, icon buttons, select and menu triggers, menu options, toggle group items, switches and choice rows all follow it. A native checkbox or radio still greys, as the browser draws it. The loading button (lc_button disabled: true, aria: { busy: true }) now keeps its colours beside its spinner.
  • lc-disabled: and lc-pending: style your own controls the same way. lc-disabled: matches a disabled control that is not busy, lc-pending: one that is, and both compose, as in has-lc-disabled:opacity-60. The helpers use lc-disabled: where they used disabled:, so a class: override of the disabled look is now written lc-disabled:.

Changes in 0.14.1

Two phone fixes, with nothing to edit:

  • The lc_search trigger is a plain icon button on phones, with no fill until it is hovered, so it matches the icon buttons beside it in a bar. From sm up it is the same filled pill.
  • lc_confirm_sheet has the ✕ on phones, at the top start like every other sheet, with the message centred in the title bar. It cancels, as Cancel does. Its label is lostcoords.ui.confirm.close.

Changes in 0.14.0

Phone sheets have one look. One option to drop, and the rest needs no edit:

  • Every phone sheet spans the screen's width and sits on its bottom edge, with round top corners and no grabber. Before, a sheet shorter than the large detent floated inset as a card with a grabber on top. detents: "fit" (the default) is now a half sheet at its content's height, up to the large detent; "large" fills the screen; "medium large" drags between the two. A swipe down still dismisses.
  • lc_dialog on phones has the sheet's title bar: the ✕ at the start, 44px on a muted circle, the title centred and the description centred under it. The bar stays pinned while the body scrolls. From sm up the dialog is unchanged.
  • sheet.close(label, **attributes) is that ✕ for a sheet with a header of its own. Put it in sheet.header; from sm up it is a plain icon button that the caller places.
  • lc_sheet no longer takes handle:, and the handle target is gone from lc-sheet. Remove handle: true and any data-lc-sheet-target="handle" element. A mouse still drags a sheet by its top 28px.
  • The page no longer shrinks back behind a large sheet. It stays in place under the sheet's backdrop. html[data-lc-sheet-page] and the --lc-sheet-page-* variables are gone, and so are --lc-sheet-p and --lc-sheet-inset.
  • lc_confirm_sheet and the emoji picker lose their grabber room on phones.

Changes in 0.13.0

Two renames to make, and the rest needs no edit:

  • tag: is as: on lc_list_group, lc_list_row, lc_list_field, lc_list_item and lc_sheet, as on every other builder that picks its element. Before: lc_sheet tag: :dialog, lc_list_row "Alerts", tag: :label. After: lc_sheet as: :dialog, lc_list_row "Alerts", as: :label. A leftover tag: no longer picks the element: it renders as a tag attribute, so search your views for it.
  • lc_dialog_class takes kind: as a keyword, like every other class helper. Before: lc_dialog_class(:context). After: lc_dialog_class(kind: :context).

Changed:

  • A split button's toggle runs your actions before the menu's. toggle: { data: { action: … } } now comes first in data-action, as trigger_attributes: does on lc_menu. lc_split_button renders through the same code as lc_menu, so the two cannot drift.

Fixed:

  • A menu in a row that a Turbo morph reordered no longer breaks the next visit. The morph moves a menu's trigger and panel, which carry ids, into the row that takes its place and removes the emptied host. That host's lc-menu failed to disconnect and left listeners behind, and the next visit threw Missing target element "popover" for "lc-menu" controller once per orphaned menu. FloatingPanel now listens to the document only while its panel is open, and no teardown reads a target; a subclass's disconnect should not read one either.
  • A trigger that a morph replaces keeps its arrow keys. lc-menu hears keys on its host, not on the trigger and panel it found when it connected.
  • Menus, popovers, dialogs, phone sheets and linked cards stay put under reduced motion. They still fade, but no longer slide, grow or lift. Before, only the document reset in base.css shortened these, so a host that skips base.css kept the movement.

New options:

  • lc_menu and lc_popover take the same options. lc_menu gains trigger_variant:, lc_popover gains side: and trigger_size:, and trigger_size: now also sizes a text trigger.

Faster:

  • lc_tw keeps one class merger for the process instead of one per view, so a class list merged in one request is a cache hit in the next.

Changes in 0.12.2

Nothing needs an edit. Fixed:

  • Back no longer brings a dialog back half open. Turbo snapshots a page with its open dialogs, and restoring one kept the open attribute without the top layer: no backdrop, focus trap or Escape, and the page stayed pinned by the scroll lock. A dialog joined through registerDialog now comes back closed and the page unpinned; a controller that reopens its dialog on connect shows it as a real modal again.

Changes in 0.12.1

Nothing needs an edit. Changed:

  • A dialog opens with focus on itself. lc-dialog and the new showDialog(dialog) helper in lostcoords/ui/helpers/dialog focus the dialog rather than its first control, so the close button no longer shows the focus ring after a tap and a first field no longer raises the keyboard. A control marked autofocus still takes focus.
  • The focus halo skips dialogs, including ones with a tabindex.

New option:

  • lc_section(header: :from_sm) hides the heading row on phones, for a section whose content explains itself on a small screen, such as a balance card. Screen readers still get the heading; its actions are hidden.

Changes in 0.12.0

One edit, and some components look different:

  • lc_menu_option takes form_attributes: for the form method: builds. Before: form: set that form's attributes. After: form: is the option button's own HTML form attribute, so an option can submit a form elsewhere on the page (type: "submit", form: "profile-form"). Rename form: to form_attributes: wherever an option passes it alongside method:.
  • A small icon button draws an 18px icon, up from 16px; icon_size: picks another.
  • lc_button_to and lc_icon_button_to wrap their button in a contents form, so the button sits in a flex or grid row as if the form weren't there. A caller's form: { class: } still merges over it. A margin or alignment class that was on the form belongs on the button now.
  • lc_list_group rounds its first and last visible child, whatever it is, instead of each row rounding itself. Non-row children and hidden rows need no corner classes.
  • lc_card(padding: :none) drops the border and clips its children to its corners, so rows reach the edge without negative margins.
  • A dialog's body no longer shrinks its children, so a long body scrolls instead of squashing buttons.
  • The choice card uses the global focus halo instead of its own outline.

New components and options, moved from apps that built them by hand:

  • lc_avatar_badge puts an icon badge on an avatar's corner: a decorative mark, a button or a file label.
  • lc_file_drop (and form.file_drop) is a dashed drop zone around a file input.
  • lc_list_row(choice: :radio, name:, value:, checked:) is a selectable row with a trailing check.
  • lc_toggle_group(layout: :inline | :stacked | :adaptive, scroll:) and lc_toggle_group_item(icon:, icon_only:): icons in segmented controls, stacked over their labels on narrow groups, and a scrolling track with faded edges.
  • lc_menu(side: :top, trigger_size:) opens upward and sizes its trigger; lc_popover_class and lc_menu_popover_class take side: too.
  • lc_icon_button(icon_size:) and the :inset variant, a page-coloured fill for buttons inside a card.
  • lc_avatar_stack(size:, overlap:), lc_emoji_picker(popover_size:), lc_input(icon:), lc_sheet(surface: :glass) with pinned sheet.header and sheet.footer parts, and lc_heading(as:).
  • registerDialog takes priority: and restoreFocus:, so a host dialog no longer registers with the dismiss stack directly. A click on the dialog's own padding no longer closes it.

Changes in 0.11.0

Nothing needs an edit. New:

  • lc_hovercard previews what a link points to, such as a profile card over a name, with the lc-hovercard controller, in the components entry. It opens on hover or keyboard focus, takes its card as content: or loads it lazily from src:, and keeps the card out of the accessibility tree as a preview of the linked page.

Changes in 0.10.0

Nothing needs an edit, but toggles look different:

  • A selected toggle pill fills solid. Before: a pressed, checked or current lc_toggle (and a variant: :pills toggle group item) had a soft primary fill, a primary edge and primary ink. After: it fills with --primary and --primary-foreground ink over a transparent border, so selecting never shifts its edge. A host that restyled the soft state for contrast can drop that override.
  • A segmented toggle group slides one indicator. Items stretch to share the track, and their corners are concentric with it. Where the browser supports anchor positioning, the current item's surface is one indicator that slides from item to item, whichever state marks it (aria-current, aria-selected, aria-checked, aria-pressed, a checked radio or active:); elsewhere each current item paints its own, as before. Items carry lc-toggle-group-item, and the track lc-toggle-group.

New components and options, moved from apps that built them by hand:

  • lc_tab_bar is a row of links styled as underlined tabs. The current tab is bold with a rounded underline in --lc-tab-bar-indicator; count: adds a muted number and fill: true shares the row. Unlike lc_tabs, each tab is a link to its own URL.
  • lc_sidebar is a sticky app sidebar that folds to an icon rail, with the lc-sidebar controller, in the shell entry. It keeps the reader's choice in a cookie the helper reads back, starts as a rail below rail_below: unless expanded, and yields sidebar.header (with the toggle), sidebar.body, sidebar.footer and sidebar.account, a row that opens an lc_menu. The lc-rail: variant styles your own content on the rail, and --lc-sidebar-indicator paints the current link's bar. If you built a sidebar with a rail variant and a cookie of your own, you can replace it and delete its stylesheet rules and controller.
  • lc_stats and lc_stat show headline numbers in a description list, in a line or as tiles.
  • lc_char_counter is the character ring X shows under a post, with the lc-char-counter controller. It counts a field, or takes a count you supply for weighted characters.
  • lc_time renders the short relative time X shows, "12m", "4h", "4 Nov", with the full date as its title.
  • lc_split and lc_columns lay out a main column beside an aside and balanced columns of groups, with lc_split_class and lc_columns_class for markup you render yourself.
  • lc_empty_state takes title:, text:, icon:, level: and card: to lay out the usual empty state; the block form still works.
  • lc_toggle takes icon:, icon_only: and tooltip:. icon_only: true makes a square toggle of just the icon whose label stays as its accessible name.

Changes in 0.9.1

Nothing needs an edit:

  • Opening a dialog, sheet or menu no longer shifts the page. The scroll lock pins the body at the width it had before locking, so the page keeps its width when the scrollbar disappears.

Changes in 0.9.0

The gem is Rails-only. It loads through its Rails engine, and the standalone ActionView mode is gone:

  • require "lostcoords/ui/action_view" and require "lostcoords/ui/rails" are removed. Use require "lostcoords/ui", or let Bundler require the gem. Both load the engine.
  • Lostcoords::Ui.view_paths, Lostcoords::Ui.load_translations! and Lostcoords::Ui.root are removed. The engine adds the gem's views and translations to the host's lookup paths. Use Lostcoords::Ui::Engine.root to locate the gem's files.
  • Components no longer call a private lc_locale. They translate with I18n.locale. Set the locale through Rails, for example with I18n.with_locale in a controller around_action.
  • The gem depends on railties instead of activesupport. An app outside Rails moves to a Rails application and the engine's asset setup above.

Rails apps that load the gem through Bundler need no edits.

New components and options:

  • lc_toc is an "On this page" list that follows the reader. It marks the section scrolled to with aria-current="location" and slides an indicator to it. Pass links with toc.link "Usage", "#usage", or rendered HTML with lc_toc(headings: html) to list its h2 and h3 that carry an id.
  • Headings and sections can link to themselves. lc_heading "Usage", id: "usage", anchor: true and lc_section title: "Usage", id: "usage", anchor: true wrap the title in a link with a # mark on hover. anchor: "section-id" links a heading to an element around it. lc_prose(anchors: true) does the same for rendered Markdown, whose headings Kiln gives ids.
  • Anchored targets clear sticky chrome. .lc-anchor-target sets a scroll margin of --lc-sticky-offset, which lc_app_header sets to 5rem while it renders. Override the property if your header is taller.
  • lc_app_header, lc_docs_shell and lc_dock move from the Blocks examples into the gem, in the new shell stylesheet entry, with the lc-app-header and lc-dock controllers. lc_app_header yields header.brand, header.nav and header.actions. lc_docs_shell(navigation:, contents:) lays out a sidebar, the page and an lc_toc. lc_dock yields dock.nav and dock.menu, reserves its height at the end of the page and hides while the on-screen keyboard is open. If you copied the Application header, Documentation layout or Mobile navigation block, you can replace the copy with the helper and delete its stylesheet and controller.

Changes in 0.8.2

Nothing needs an edit. New options, and one change you may see:

  • lc_emoji_picker takes picker_class:, trigger_class: and popover_class:. The gem leaves the desktop popover unpainted so the host can match its own floating surfaces; until now that meant rendering the lostcoords/ui/components/emoji_picker partial directly. Pass the classes to the helper instead.
  • A dialog slides to a new width. .lc-dialog transitions inline-size, so a dialog that widens, such as one opening a side panel, animates instead of jumping. A host that restated the dialog's transition only to add inline-size can delete that rule.
  • lc-scroll-keeper keeps a scroll container's position. Put data-controller="lc-scroll-keeper" on a sidebar that every page renders again; it restores its scroll across Turbo visits and reloads.
  • lc_nav_list keeps the server's current link after a back visit. Before: a page restored from Turbo's cache showed the link clicked before leaving as current. After: it shows the one the server marked.

Changes in 0.8.1

Nothing needs an edit, but these look different:

  • A secondary destructive button has a soft destructive fill. Before: variant: :secondary, tone: :destructive kept the neutral secondary fill with destructive ink. After: it fills with the same soft destructive mix a destructive ghost button shows on hover, so the tones read solid, soft, then ink only.
  • Toggles style aria-checked. An lc_toggle_class element with aria-checked="true" now looks pressed, so toggle pills can be the radios of a variant: :pills toggle group.
  • A toggle's fill follows --lc-field-bg. Before: lc_toggle always filled with --input. After: it reads --lc-field-bg like fields and the select trigger, so on a card or list row it takes --card-input.
  • The emoji picker's skin-tone menu opens downward. Before: it opened above its toggle, which sits in the picker's top row, so it escaped the picker. After: it opens below the toggle, inside the picker.
  • A card's destructive edge ignores its closed menus. Before: a destructive option in a menu or popover inside a card (a row's "Remove") tinted the card's edge. After: only the card's own controls and invalid fields do.

Upgrading from 0.7

Everything else in 0.8 is additive. These changes need edits in an app built on 0.7:

  • A named lc_toggle_group renders native radios. Before: lc_toggle_group(name:) rendered radio buttons, a hidden input and the lc-selection controller. After: each item is a label around an input type=radio with that name, so listen for the inputs' change instead of lc-selection:change, and mark the selected item with checked: or the group's value: instead of selected:. A group without name: keeps the radio buttons and lc-selection:change; it no longer has an input target.
  • lc_sheet_data is gone. Before: tag.dialog data: lc_sheet_data({ controller: "picker" }, detents: "large"). After: lc_sheet as: :dialog, detents: "large", data: { controller: "picker" }. lc_sheet also renders non-dialog sheets, so drop any hand-written data-controller="lc-sheet" and handle element too.
  • The lc-confirm-dialog controller is gone. Before: a pre-rendered confirm <dialog> wired to lc-confirm-dialog. After: render lc_confirm_sheet once in the layout and put data-turbo-confirm on the form, with data-turbo-confirm-description, data-turbo-confirm-accept and data-turbo-confirm-tone for its description, label and tone.
  • A modal lc_dialog is 32rem wide on desktop. Before: min(92vw, 31rem). After: size: :md, min(32rem, 100vw - 2rem). Pass size: :sm (24rem) for a narrower dialog, or set --lc-dialog-width.
  • lc_dialog puts your content in a body slot. Before: the block rendered straight after the header inside [data-slot=dialog-content]. After: it renders inside [data-slot=dialog-body], which scrolls on desktop, and the close button sits in [data-slot=dialog-actions]. Update CSS that selects children of dialog-content.
  • A swiped-away popover sheet hides itself. Before: lc-sheet:dismiss only notified listeners on a non-dialog sheet. After: an open [popover] sheet hides unless a listener calls preventDefault().
  • An unpadded lc_card no longer gaps its children. Before: lc_card(padding: :none) stacked its children --lc-inset apart. After: they meet edge to edge, as rows and empty states in an unpadded card expect. Pass class: "gap-inset" to keep the old spacing.
  • lc_text(size: :label) is semibold. Before: weight 500. After: 600, the same as a field label, so one label role serves both. Add class: "font-medium" where the lighter weight was intended.

Components

Installation and setup · Live examples. Each example renders the same ERB source shown in its code panel. The API reference reads signatures from the helper definitions. API JSON and llms.txt include those signatures and the runnable examples.

Buttons use primary, secondary, outline, ghost, inset, glass or destructive, with sm, md or lg sizes. inset fills with the page colour and muted ink, for a quiet control on a card. Primary, secondary and destructive buttons have visible filled surfaces. Ghost buttons and the lc_icon_button toolbar action are transparent at rest and show their full shape on hover. Primary, secondary and destructive buttons are flat. Secondary buttons use a soft neutral fill distinct from page and card backgrounds. Outline buttons have a transparent fill and a visible edge. Glass buttons use the shared translucent material, rim and shadow for floating controls. The default light theme uses white pages and softly shaded cards, with no visible card borders or resting shadows. Menu and popover triggers accept trigger_variant using the same button variants. Button hover and press fills mix 94% of the base background with 6% of its foreground in OKLab. Ghost and icon buttons stay transparent at rest and use the secondary base for that calculation. Apps can override --secondary for the neutral base, or --lc-button-bg and --lc-button-ink on individual buttons. Inputs use --input and --lc-input-hover. lc_button_to preserves Rails' form, HTTP method and CSRF behavior. Its form is display: contents, so the button sits directly in the caller's row or grid; form: { class: } merges over that. lc_icon_button_link_to and lc_icon_button_to are the link and form versions of lc_icon_button; a block replaces its icon with custom content. Icon buttons take lc_button's variant: and tone: too; the default :ghost is the quiet toolbar look. Their icon is 18, 20 or 24px for sm, md or lg; icon_size: picks another of those tiers, as in size: :sm, icon_size: :md. block: true makes any button full width. Block helpers capture ERB content. Use icon: "plus" for a leading Heroicon or icon_position: :end for a trailing one. Custom icons and spinners use data-icon="inline-start" or data-icon="inline-end"; buttons adjust that edge's padding. lc_button(expanded_icon: "x-mark") swaps its content for that icon while aria-expanded is true, for a trigger that closes what it opened; the content stays as the accessible name. lc_button(as: :span) renders the look without a control, for a decorative button inside a larger target such as a file drop zone's label; give it aria: { hidden: true } when the target already names the action. tone: :destructive recolours any variant for destructive actions and keeps its emphasis: a ghost or outline button takes destructive ink, a secondary button a soft destructive fill (the ghost button's hover), and a primary button becomes the filled variant: :destructive surface. lc_select_trigger is a button that looks like lc_select, for buttons that open a menu or picker. Its label starts at the inline start and its chevron sits at the inline end and turns while aria-expanded is true. lc_split_button is one pill with two targets: a primary action, a link with href:, and a square toggle named by menu_label: that opens a menu of the block's lc_menu_option items. The toggle draws a divider from its ink and keeps its pressed fill while open. It takes the button's variant:, tone:, size: and icon:; action:, toggle: and menu: add attributes to those parts.

<%= lc_button_to "Archive", project_path(@project), method: :delete, variant: :destructive %>
<%= lc_button_to "Revoke", api_key_path(@key), method: :delete, variant: :ghost, tone: :destructive %>
<%= lc_select_trigger "All members", aria: { haspopup: "menu", expanded: false } %>
<%= lc_split_button "Add expense", id: "add-menu", href: new_expense_path, icon: "plus", menu_label: "More ways to add" do %>
  <%= lc_menu_option "Import a CSV", icon: "arrow-down-tray" %>
<% end %>
<%= lc_icon_button "Settings", icon: "cog-6-tooth" %>
<%= lc_icon_button_link_to "Back", projects_path, icon: "chevron-left" %>
<%= lc_icon_button_to "Delete", attachment_path(@attachment), icon: "trash", method: :delete %>
<%= lc_icon_button "Account" do %><%= lc_avatar current_user.initials %><% end %>

<%= lc_button block: true, data: { action: "editor#save" }, aria: { busy: true } do %>
  <%= lc_spinner size: :sm %>
  Saving…
<% end %>

A disabled control that is also aria-busy="true" is pending: it keeps its enabled look and a progress cursor but can't be pressed, so a control waiting for its script or its request doesn't flash grey. Style your own controls with the lc-disabled: and lc-pending: variants, which tell the two apart.

Use native attributes for application behavior, class: to merge additional Tailwind utilities, and theme tokens to restyle the library. popover: true renders popover="auto", as a bare popover attribute does, with the lc-light-dismiss controller: it makes the popover manual once it connects and closes it itself on a tap outside, Escape, a popovertarget button that hides it, or a click on an element inside marked data-lc-popover-close, so its exit plays in Safari too. Without JavaScript it stays a native auto popover. lc_field yields the input's id and validation attributes so labels, hints and errors stay connected. Linked cards use lc_card(href: ...); cards containing buttons or fields remain ordinary containers.

lc_table renders a native table with a shaded header and subtle row dividers. Supply the caption, header cells and body in its block. Wrap wide tables in an app-owned horizontal scroll region with an accessible name and keyboard focus. Use lc_table_class when an existing table renderer owns the markup.

Cards share one API: lc_card(padding: :md), with :sm and :none for tighter or custom spacing. Padding sizes set --lc-inset, so content inside follows the card. An unpadded card drops its border and clips its children to its corners, so full-bleed rows meet its edge and a hovered row's fill rounds with it, with no negative margins or corner classes. Menus and dialogs inside it render in the top layer and are not clipped. Fields and secondary buttons inside cards take --card-input and --card-secondary, which default to the page fills; set them in the theme when --card equals --input or --secondary, or set --lc-field-bg to change fields in one context. Cards provide avatar cutouts and a validation border when they contain errors. Fills that are muted on the page switch so they stay visible on the card: choice tiles, alerts, neutral badges and skeletons take the page background (--lc-tile-bg), and toggle group and tab tracks take the accent fill (--lc-track-bg). Set either variable to apply the same context to your own muted surface. Add class: "@container" when a card owns its width and its children use container queries. Use --lc-card-bg, --lc-card-border, --lc-card-radius and --lc-card-shadow for local appearance overrides.

lc_badge handles labels, counts and status. Pass shape: :pill for a fully rounded label such as "You" or an error count. lc_icon_badge handles decorative icon containers: pass icon: for a library icon, or content or a block for an emoji. It takes shape: :square, :circle or :plain (no tile and a larger glyph, as at the start of a list row) and sm (26px), md (40px), lg (48px) or xl (56px) sizes. lc_avatar sizes are xs (20px), sm (26px), md (32px), lg (48px), xl (96px) and xxl (112px). Between them, both take a step on the spacing scale, as in size-7: lc_avatar takes 7 (28px) and 11 (44px), lc_icon_badge takes 6 (24px), 7 (28px) and 11 (44px). Pass as: :button when the avatar is itself the control, such as a colour picker's trigger. lc_avatar_badge(icon, label:, as:) pins a round badge to an avatar's bottom corner; render it after the avatar in a relative wrapper. as: :span (the default) is a 28px decorative mark, such as a lock on a gated group; as: :button and as: :label are 44px controls named by label:, such as a camera that changes the photo. A label needs for: and shows the focus halo while the visually hidden input after it has focus; as a menu trigger, splat menu.trigger's attributes into an as: :button badge. lc_avatar_stack takes row: attributes for the inner row that overlaps the avatars, such as a controller target. Its size: (xs, 5.5, sm, md or lg) pins every avatar in it to one size, and overlap: :sm tucks them closer and drops the row's padding, for a stack in a line of text. compact: true is a preset of both and takes neither. Initials and icons scale with the size, including a size set through --lc-avatar-size or --lc-icon-badge-size; set --lc-avatar-font-scale or --lc-icon-badge-font-scale to change the share, or the -font-size variable to pin it. Badge, icon badge, Alert and Toast share neutral, primary, success, warning and destructive tones.

lc_toggle renders a button that flips its own aria-pressed; set aria-pressed or aria-expanded yourself and it leaves the state to your controller. href: renders a link marked aria-current when active, and name: with value: a label around a visually hidden native radio, styled by :checked. icon: adds a leading icon, and icon_only: true makes a square toggle of just that icon whose label stays as its accessible name; tooltip: true shows the label on hover and focus, as on lc_icon_button. lc_toggle_group with lc_toggle_group_item holds mutually exclusive choices, and the group decides what its items are. With name: they are native radios in labels, which bring their own arrows, submitted value and reset; items take value: and checked:, and the group's value: checks the matching item. With as: :nav they are links in a labelled nav; items take href: and current:. Otherwise they are radio buttons whose selection lives in the lc-selection controller, which dispatches lc-selection:change; items take value: and selected:. An item given another kind's arguments raises. variant: :pills lays any of them out as wrapping toggle pills, sized by size:, instead of a segmented track; with scroll: true (or :narrow, only inside a container under @md) the pills stay in one row that scrolls sideways. Items take icon: and icon_only: as lc_toggle does. A segmented group's layout: :stacked puts each item's icon over its label, and layout: :adaptive makes the group full width and stacks its items only while the group is narrower than 24rem. scroll: true lets a track wider than its container scroll sideways, its edges fading.

<%= lc_toggle_group label: "Period", as: :nav do %>
  <%= lc_toggle_group_item "Month", href: stats_path(period: :month), current: true %>
  <%= lc_toggle_group_item "Year", href: stats_path(period: :year) %>
<% end %>
<%= lc_toggle_group label: "Billing", name: "billing", value: "monthly" do %>
  <%= lc_toggle_group_item "Monthly", value: "monthly" %>
  <%= lc_toggle_group_item "Annual", value: "annual" %>
<% end %>
<%= lc_toggle "Food", aria: { pressed: false }, data: { value: "food" } %>
<%= lc_toggle "Bold", icon: "bold", icon_only: true, tooltip: true %>
<%= lc_toggle_group label: "View", as: :nav do %>
  <%= lc_toggle_group_item "List", href: "/", current: true, icon: "list-bullet", icon_only: true %>
  <%= lc_toggle_group_item "Calendar", href: "/calendar", icon: "calendar-days", icon_only: true %>
<% end %>

lc_emoji_picker(popover_size: :lg) widens the desktop popover from 22rem to 28rem for a roomier grid.

lc_empty_state(title:, text:, icon:) lays out the usual empty state: a round icon badge, a heading (level:, 2 by default), a line of muted text, then the block, such as an action. card: true puts it on a card. Without those options the block is the whole content, as before.

<%= lc_empty_state title: "No drafts yet", text: "Drafts appear here until you post them.", icon: "pencil-square", card: true do %>
  <%= lc_button_link_to "New draft", new_draft_path, icon: "plus" %>
<% end %>

lc_stats shows headline numbers as a description list of lc_stat items: the value in bold tabular figures and its label in muted text. layout: :inline (the default) runs them along a line; layout: :grid gives each a tile, in columns: 2, 3 or 4, or as many as fit. tone: colours a value with a status tone, and a block replaces the value, such as a link around it.

<%= lc_stats do %>
  <%= lc_stat number_with_delimiter(@replies), label: "replies sent", tone: :primary %>
  <%= lc_stat(label: "people") { link_to @people, people_path } %>
<% end %>
<%= lc_stats layout: :grid, columns: 2 do %>…<% end %>

lc_time(time) renders a <time> with the short text X shows: "now", "12m" and "4h" within a day, then "4 Nov", and "4 Nov 2025" in another year. The full date and time is its title, and detail: adds to it. The texts and date formats are translations under lostcoords.ui.time; month names come from the host's date.month_names, as rails-i18n provides them, and fall back to English. now: sets the moment to count from.

lc_collapsible expands content through a native <details> element. lc_alert renders persistent inline feedback; lc_toast adds timed dismissal.

<%= lc_collapsible card: false, indicator: :chevron, summary_class: "rounded-2xl px-3 hover:bg-accent" do |collapsible| %>
  <% collapsible.summary do %><span class="me-auto">Language</span><span>English</span><% end %>
  …
<% end %>

The summary part replaces title: with your own markup and takes attributes for the <summary>. card: false drops the card surface, summary_class: adds classes to the summary, button: { variant:, tone:, size: } makes the summary look like that lc_button without the native marker, and indicator: is :marker (native), :chevron (turns as it opens) or :none.

<%= lc_list_section "Security", id: "security", footnote: "Keep one way to sign in." do %>
  <%= lc_list_group do %>
    <%= lc_list_row "Email", subtitle: "ada@example.com", icon: "envelope" do %>
      <%= lc_button "Change", variant: :secondary, size: :sm %>
    <% end %>
    <%= lc_list_row "Alerts", as: :label do %><%= check_box_tag :alerts, class: lc_switch_class %><% end %>
  <% end %>
<% end %>

lc_list_group draws grouped settings rows: each row is its own card-coloured panel, 2px apart, and only the group's ends round. The group rounds its first and last shown child, so a collapsible or any other element at an end rounds too, and a hidden row hands its corners to the next one shown. Rows are card surfaces, so fields and buttons in them follow --card-input and --card-secondary. lc_list_row with a title lays out icon: (a name, or your own markup such as a logo), the title, subtitle: and the block as trailing content; as: makes it a label, li, details or a (href:). href: with as: :li or :div links the title instead and stretches it over the row, so the block can hold buttons and links of its own; a click anywhere else in the row follows the title. Without a title the block is the whole row, and padded: false leaves the padding to content such as an lc_list_item button or summary, which lays out the same icon, title and subtitle inside your own element. lc_list_section adds the heading and footnote; with an id:, the heading labels the section. Put a form around lc_list_group inside it when the rows save together.

lc_list_row(choice: :radio, name:, value:, checked:) makes a row one choice of a radio group: a label around a visually hidden radio, then the title or block, then a check shown while it is checked. The checked row fills with --primary-soft and its text turns semibold, and the focus halo rings the row while its radio has focus. input: adds attributes to the radio, such as required: true or a Stimulus action.

<%= lc_list_group role: "radiogroup", aria: { label: "How did you hear about us?" } do %>
  <%= lc_list_row "A friend", choice: :radio, name: :heard_about, value: "friend", checked: true %>
  <%= lc_list_row "Search", choice: :radio, name: :heard_about, value: "search" %>
<% end %>

lc_list_field is a form row in the same group: a label column, then the block as the control. In a narrow row the label folds to its icon:, and the text stays the accessible name. id: makes the label a <label> for that control; as: :fieldset names a group of controls, such as chips, with a legend. as: :span, surface: false draws the row inside another element, such as a collapsible's summary. lc_input(plain: true) drops the field's fill, border, padding and height so the text sits in the row, which tints and shows the focus ring while that input has focus. Toggles take --lc-field-bg like fields, so on a card or list row they use --card-input.

<%= lc_list_group do %>
  <%= lc_list_field "Description", icon: "pencil", id: "description" do %>
    <%= lc_input plain: true, id: "description", name: "description" %>
  <% end %>
  <%= lc_list_field "Paid by", icon: "user", as: :fieldset do %>
    <div class="flex flex-wrap gap-related"><%= lc_toggle "Ada", size: :sm, aria: { pressed: true } %></div>
  <% end %>
<% end %>

Parts and slots

Compound components yield a builder, so their parts are scoped and discoverable. A card stacks its parts with the same gap it pads with:

<%= lc_card do |card| %>
  <%= card.header title: "Members", description: "People in this workspace" do %>
    <%= lc_button "Invite", size: :sm %>
  <% end %>
  <%= card.content do %>…<% end %>
  <%= card.footer do %><%= lc_button "Save" %><% end %>
<% end %>

<%= lc_alert "Your card was declined.", title: "Payment failed" do |alert| %>
  <%= alert.actions do %><%= lc_button "Update payment", size: :sm %><% end %>
<% end %>

<%= lc_dialog id: "new-project", title: "Create project", description: "Projects group pages." do |dialog| %>
  …
  <%= dialog.footer do %><%= dialog.close %><%= lc_button "Create" %><% end %>
<% end %>

Every component root and part carries data-slot, plus data-variant, data-size or data-tone where they apply, so a context can restyle parts without matching utility classes: [data-slot=card-footer] { justify-content: start }.

Forms

lc_form_with is form_with with Lostcoords::Ui::FormBuilder. Standard helpers keep their Rails signatures and render library controls; field adds the label, hint and the attribute's errors, and sets aria-invalid on the control. Rails' field_with_errors wrapper does not affect the layout.

<%= lc_form_with model: @project, gap: :content do |form| %>
  <%= form.field :name, hint: "Shown to members" %>
  <%= form.field :email, as: :email_field %>
  <%= form.switch :public %>
  <%= form.submit "Save project" %>
<% end %>

gap: makes the form a stack and card: true (with padding:) makes the form the card, so neither needs a wrapper element. Nested fields_for builders render library controls too, and form.check_box :x, role: "switch" draws a switch inside a label row you build yourself. form.submit and form.button take lc_button's variant:, tone:, size: and block:.

A symbol size: such as size: :sm picks the control height; an integer still sets the HTML attribute. form.field … size: :sm (or lc_field size: :sm) is the compact field for dense forms, with a caption label. Pass builder: Lostcoords::Ui::FormBuilder to form_with directly, or call lc_field with error: record.errors.full_messages_for(:name) when you keep your own builder.

lc_char_counter(max:) is the ring X shows under a post: it fills as a field nears max: characters, hides while the field is empty, turns to the warning tone with the characters left once warn: (20) or fewer remain, and to the destructive tone with a negative number past the limit. Its accessible name reads "120 of 280 characters". It counts the field whose id is for:, or the nearest field around it. To count another way, such as X's weighted characters, set data-lc-char-counter-count-value or send it an event whose detail.count is the count, as in data: { action: "composer:count@window->lc-char-counter#update" }; count: renders a count before JavaScript runs.

<%= lc_field label: "Post", id: "post" do |field| %>
  <%= lc_textarea name: "post[text]", rows: 4, **field %>
  <%= lc_char_counter max: 280, for: "post" %>
<% end %>

lc_file_drop(title:, hint:, button:, icon:) is a dashed drop zone: a label around a visually hidden file input, so a click or a dropped file reaches it. name: builds the input with accept:, multiple: and input: attributes, such as a controller target; form.file_drop :files, title: … wraps the form's own file_field, and its other options (accept:, multiple:, data:) reach the input. button: adds a decorative button inside, which the label already names.

<%= form.file_drop :files, title: "Add receipts", hint: "Up to 10 MB each", button: "Browse",
      multiple: true, accept: "image/*,application/pdf", data: { action: "change->upload#update" } %>

lc_input(icon: "magnifying-glass") draws a leading icon inside the field. The input comes wrapped in a span then; class: and the other attributes still reach the <input>.

lc_checkbox, lc_radio and lc_switch render native inputs with a label and optional hint. Checkboxes and switches submit an unchecked value like Rails' check_box; pass unchecked_value: nil to omit it. A nil label renders the bare input, for a row selector the row labels; give it aria: { label: }. lc_choice_group groups them in a fieldset with a legend, hint and error.

lc_fieldset(legend:, id: nil, hint: nil, error: nil, size: :md) names a group of controls that no single label can, such as toggles, a picker or several inputs; with an id, its hint and error describe the fieldset, and size: :sm matches a compact lc_field. lc_choice_group is lc_fieldset with its choices stacked. Text that labels something other than one control, such as a list, uses lc_text size: :label, the field label's role.

Navigation and overlays

<%= lc_breadcrumb [ [ "Projects", projects_path ], @project.name ] %>

<%= lc_tabs id: "project-tabs", label: "Project" do |tabs| %>
  <% tabs.panel "Overview" do %>…<% end %>
  <% tabs.panel "Activity", value: :activity do %>…<% end %>
<% end %>

<%= lc_tooltip "Copy a link", id: "copy-tip" do |tip| %>
  <%= lc_icon_button "Copy link", icon: "link", **tip %>
<% end %>

<%= lc_icon_button "Stop", icon: "stop", tooltip: true %>

<%= lc_description_list do |list| %>
  <%= list.item "Owner", @project.owner.name %>
  <%= list.item("Plan") { lc_badge @project.plan } %>
<% end %>
<%= lc_tab_bar label: "Drafts", fill: true do |bar| %>
  <%= bar.link "Open", drafts_path, current: true, count: @open_count %>
  <%= bar.link "Posted", drafts_path(status: :posted), count: @posted_count %>
<% end %>

lc_tab_bar is a row of links styled as underlined tabs, for the views of a page that each have a URL; use lc_tabs when the panels live on one page. The current tab carries aria-current="page", bold text and a rounded underline in --lc-tab-bar-indicator (the primary color by default). count: adds a muted number after the label, and fill: true stretches the tabs to share the row. A row too long for its container scrolls sideways and fades at the edge it continues past.

Tabs follow the ARIA tabs pattern with arrow key, Home and End navigation, and dispatch lc-tabs:change. orientation: :vertical stacks the tabs beside their panels and moves with Arrow Up and Down; activation: :manual moves focus with the arrows and selects with Enter or Space; list: adds attributes to the tab list. Icon buttons take tooltip: true to show their label, or tooltip: "text" to describe themselves with other text. A tooltip without an id: repeats its trigger's label and stays hidden from assistive technology. Tooltips show on hover and keyboard focus, Escape hides them, and they describe their trigger, in the top layer; keep essential information visible. Description lists stack on phones and use two columns from sm.

<%= lc_skip_link %>

<%= lc_nav_list label: "Settings" do |nav| %>
  <%= nav.group "Workspace" do %>
    <%= nav.link "General", settings_path, current: current_page?(settings_path) %>
    <%= nav.link "Members", members_path %>
  <% end %>
<% end %>

<%= lc_pager previous: [ "Install", install_path ], next: [ "Theming", theming_path ] %>

Read the <%= lc_link "guide", guide_path %>.
<%= lc_nav_list label: "Project", layout: :responsive, indicator: true do |nav| %>
  <%= nav.link "Overview", project_path(@project), icon: "document-text", current: true %>
  <%= nav.link "Activity", project_activity_path(@project), icon: "clock" %>
<% end %>

lc_nav_list marks the current link with aria-current="page". Its default layout: :column is a sidebar, where compact: true is the quieter style for an "On this page" list and indent: true nests a link. layout: :row lays links in a line, :dock stacks each icon above its label in equal cells for a phone's bottom bar, and :responsive is a dock below sm and a row from sm; position a dock yourself, such as fixed bottom-0. indicator: true slides one fill to the current link, and after a Turbo visit the new list starts the fill where the last one left it. Set --lc-nav-indicator (or --lc-nav-dock-indicator for a dock, such as one on glass) to change the fill, and pass layout: to lc_nav_link_class for links you render yourself. lc_pager takes [title, url] for each side and compact: true for icon buttons. lc_link has inherit, muted and primary tones; lc_link_class styles links you render yourself. lc_skip_link targets #main by default. Pass card: true to lc_radio or lc_checkbox for selectable tiles; a block adds content, such as a preview, under the label.

A sidebar that scrolls on its own starts at the top on every page. Put data-controller="lc-scroll-keeper" on the scroll container to keep its position across Turbo visits and reloads. Containers with the same data-lc-scroll-keeper-key-value share one position for the browser tab. Without a saved position, it scrolls the aria-current="page" link into view.

Page chrome lives in the shell stylesheet entry. lc_app_header is a sticky glass header, lc_docs_shell lays out a documentation page, and lc_toc lists the page's sections and marks the one the reader has scrolled to. This documentation site is built with them.

<%= lc_app_header do |header| %>
  <%= header.brand root_path, label: "Acme home" do %><%= image_tag "logo.svg", alt: "" %> Acme<% end %>
  <%= header.nav class: "max-sm:hidden" do |nav| %>
    <%= nav.link "Guides", guides_path, current: true %>
  <% end %>
  <%= header.actions do %><%= lc_icon_button "Search", icon: "magnifying-glass", size: :sm %><% end %>
<% end %>

<% contents = lc_toc do |toc| %>
  <%= toc.link "Usage", "#usage" %>
  <%= toc.link "Sizes", "#sizes", indent: true %>
<% end %>
<%= lc_docs_shell navigation: render("guides/sidebar"), contents: do %>
  <%= lc_section title: "Usage", id: "usage", anchor: true do %>…<% end %>
<% end %>

lc_sidebar is a sticky, full-height app sidebar that folds to an icon rail. Its toggle stores the choice in a cookie (cookie:, lc_sidebar by default) that the helper reads back, so the server renders the next page the same way; state: "collapsed" or "expanded" overrides it. Below rail_below: (:xl by default; :md, :lg, :2xl, or false for never) it starts as a rail unless the reader expanded it. On the rail, lc_nav_list group titles and link labels stay for screen readers only and links center their icons, so give each link a title:. The current link gets a bar at the sidebar's edge in --lc-sidebar-indicator (any background, such as a gradient). --lc-sidebar-width (15rem) and --lc-sidebar-rail-width (4rem) set the widths, and the lc-rail: variant styles your own content on the rail, as in lc-rail:hidden. It dispatches lc-sidebar:toggle with { collapsed }.

<%= lc_sidebar cookie: "sidebar" do |sidebar| %>
  <%= sidebar.header do %>
    <%= link_to root_path, aria: { label: "Acme home" } do %>
      <span class="lc-rail:hidden">Acme</span><span class="hidden lc-rail:inline" aria-hidden="true">A</span>
    <% end %>
  <% end %>
  <%= sidebar.body do %>
    <%= lc_nav_list label: "Main", indicator: true do |nav| %>
      <%= nav.link "Inbox", inbox_path, icon: "inbox", title: "Inbox", current: true %>
    <% end %>
  <% end %>
  <%= sidebar.footer do %>
    <%= sidebar.account current_user.name, detail: current_user.email, avatar: lc_avatar(current_user.initials, size: :sm) do %>
      <%= lc_menu_option "Settings", icon: "cog-6-tooth", href: settings_path %>
      <%= lc_menu_option "Sign out", href: session_path, method: :delete %>
    <% end %>
  <% end %>
<% end %>

sidebar.header renders the toggle after its block (toggle: false leaves it out; sidebar.toggle renders it anywhere). sidebar.account is a full-width row, the avatar, name, a detail line and an ellipsis, that opens an lc_menu of the block's options; on the rail only the avatar shows.

For rendered Markdown, such as a Kiln .md view, pass the HTML to both: lc_prose(anchors: true) { html } links its headings, and lc_toc(headings: html) lists them. On phones, lc_dock floats dock.nav and a dock.menu of quick actions at the bottom of the screen; render it last, since it reserves its height there.

<%= lc_menu id: "member-actions", label: "Actions for #{member.name}", trigger: :icon do %>
  <%= lc_menu_option "Rename", icon: "pencil" %>
  <%= lc_menu_option "Euro", hint: "EUR", leading: tag.span("€"), checked: true %>
  <%= lc_menu_option "Remove", icon: "trash", href: member_path(member), method: :delete, tone: :destructive %>
<% end %>

Menu options take a leading icon: or other rendered leading: content, which is hidden from assistive technology so the label stays the name. Leading visuals share one column across the menu, so labels line up with and without them. hint: adds a secondary line. checked: true or false makes a menuitemradio with a check mark. checkbox: true makes a menuitemcheckbox that flips its aria-checked on click, dispatches lc-menu:check with { checked }, and leaves the menu open. method: renders a button_to form and passes params: on, and form_attributes: to the form. form: is the button's own attribute: with type: "submit" the option submits that form from elsewhere on the page. lc_menu_group(label, id:) wraps options in a role="group" labelled by an eyebrow heading; its options stay on the menu's columns. lc_menu and lc_popover take trigger: false to render only the panel, named by label: (or title:), when an ancestor hosts the lc-menu or lc-popover controller and wires its own trigger targets. With click->lc-popover#toggleFromRow on that host, a click anywhere on it that misses a control opens the panel; mark other regions data-lc-menu-ignore. lc_menu and lc_popover take trigger: :icon with icon: for a quiet icon button named by label:, or rendered content such as an avatar for a custom trigger. trigger_size: :sm makes any trigger a small control, and trigger_variant: picks the button variant of a text trigger. side: :top opens the panel above its trigger, for one near the bottom of the screen. trigger_attributes: adds attributes such as class: or title: to either. For any other trigger, call the yielded part's trigger with a block. It receives the attributes that wire an element as the trigger (its id, aria-haspopup, aria-expanded, aria-controls and the Stimulus target and action), merged with any passed to trigger, and the element it renders replaces the default button:

<%= lc_menu id: "member-filter", label: "Member" do |menu| %>
  <% menu.trigger(class: "min-w-44") { |attrs| lc_select_trigger "All members", **attrs } %>
  <%= lc_menu_option "Alex" %>
<% end %>

The icon trigger is muted at rest, with full ink and a slightly larger icon on hover, focus and while open. wrapper_attributes: styles the element that holds the trigger and panel, an inline-flex box by default, for example class: "flex min-w-0" when the trigger fills a grid cell. A data: { controller: } there joins the panel's own.

lc_dialog handles modal content and the mobile sheet layout: on phones it is a sheet across the screen's width, with the ✕ at the start of its title bar and the title centred. The default detents: "fit" is a half sheet at its content's height; "large" fills the screen and "medium large" drags between half and full. Icon buttons, avatar groups, motion and mobile dialogs appear with their parent component examples.

size: sets the desktop width: :sm (24rem), :md (32rem, the modal default), :lg (40rem) or :xl (64rem). Content marked data-dialog-size="xl" (any size) switches the dialog to that size while it is in the dialog, for a step that needs more room. The size sets --lc-dialog-width, so content can size itself with calc(var(--lc-dialog-width) - 2px). On desktop the header stays put and the body scrolls; an anchored dialog stops 1rem above the viewport's bottom edge. dialog.actions adds content to the header, before the close button. dialog.trigger { |attrs| … } renders your own element as the trigger, like menu.trigger: splat **attrs into it to wire it to open the dialog. Pass trigger: false when a controller of your own opens the dialog: only the <dialog> renders, and close_action: (default "lc-dialog#close") and close_label: wire the close buttons to it. data: and aria: reach the <dialog>; title_attributes: and description_attributes: reach the heading and description, for a controller that rewrites them.

<div data-controller="import">
  <button type="button" data-action="import#open">Import</button>
  <%= lc_dialog id: "import", title: "Import", trigger: false, size: :lg, close_action: "import#close",
        data: { import_target: "dialog" } do |dialog| %>
    …
  <% end %>
</div>

lc_confirm_sheet replaces the browser's confirm for data-turbo-confirm. Render it once in the layout and hand Turbo the gem's function:

import { confirm } from "lostcoords/ui/helpers/confirm"
Turbo.config.forms.confirm = confirm

The sheet shows the message as its title, Cancel and a confirm button. The submitter, then the form, can add data-turbo-confirm-description (a line under the title) and data-turbo-confirm-accept (the confirm button's label; without it a short submitter label is used). The confirm button is destructive when either has data-turbo-confirm-tone="destructive", or the submitter is an lc_button_to with variant: :destructive or an lc_menu_option with tone: :destructive. Confirming from an lc_menu opens the sheet beside the menu on desktop. ask(message, { description, accept, destructive, anchor }) from the same module opens it from your own code and resolves to true or false.

lc_sheet renders any other phone sheet, with the lc-sheet controller wired. as: :dialog makes a modal <dialog> sheet, which is what lc_dialog and lc_confirm_sheet render; with size: it gets lc_dialog's frame and width without its header, for content that brings its own. The default as: :div shows while it is :popover-open or carries [data-open], so a native [popover] and a FloatingPanel picker both work; a div you toggle yourself sets data-open and removes it to slide out. From sm up the div keeps your frame, or anchored: true makes it a popover under its trigger inside a positioned ancestor. detents: takes the same stops as lc_dialog. A swipe down dispatches lc-sheet:dismiss; unless a listener cancels it, an open popover then hides. surface: :glass draws a div in the translucent menu material, as a picker that is a menu on desktop and a sheet on phones. The block gets a builder: sheet.close "Close" is the ✕ every phone sheet has at the start of its header, and sheet.header and sheet.footer stay pinned to the top and bottom of the scrolling content, painted with the sheet's surface (--lc-sheet-bg on phones, --popover above), so content scrolls under them. Put the footer last in a scroller padded with px-inset; it bleeds to the scroller's edges and clears the home indicator.

<%= lc_sheet as: :dialog, size: :lg, aria: { label: "New expense" } do |sheet| %>
  <%= sheet.header do %>
    <h2 class="mx-auto">New expense</h2>
    <%= sheet.close "Close", data: { action: "expense#close" } %>
  <% end %>
  <div class="min-h-0 overflow-y-auto px-inset">
    …
    <%= sheet.footer do %><%= lc_button "Save" %><% end %>
  </div>
<% end %>

A controller that opens a <dialog> itself shows it with showDialog(dialog) and joins it to the dismiss stack with registerDialog, both from lostcoords/ui/helpers/dialog. showDialog opens it modal with focus on the dialog itself, so no focus ring lands on its close button and no keyboard rises for a first field; a control marked autofocus still takes focus. With registerDialog, Escape, a backdrop click and a swipe close it, and the page stops scrolling behind it. registerDialog(dialog, { close, priority, restoreFocus, lockScroll }): close may return false to keep the dialog open, such as while it asks to discard changes; priority ranks it against panels open in it (a dialog is 10, a panel 20); restoreFocus runs after a close; lockScroll: false leaves the page scrollable. It returns the unregister function and ends when the dialog closes; a click on the dialog's own padding does not close it. closeDialog(dialog, returnValue) closes it and returns a promise that settles once it has left, closed and with its exit over; clear up after a dialog (empty its frame, remove it) when that settles, not when close() returns, since Safari keeps a dialog open while its exit plays.

<button type="button" popovertarget="filters">Filters</button>
<%= lc_sheet id: "filters", popover: "auto", class: "sm:w-80 sm:rounded-3xl sm:bg-popover",
      data: { action: "lc-sheet:dismiss->filters#reset" } do %>…<% end %>

lc-popover-shell gives a native [popover] menu the same enter and exit as FloatingPanel panels; hidePopoverAfterExit(popover) from lostcoords/ui/helpers/top_layer hides one from your own code with its exit, as lc-light-dismiss does. Set --lc-popover-from to change the closed pose and an origin-* utility for where it grows from.

lc_hovercard previews what a link points to, such as a profile over a name, with the lc-hovercard controller. The card opens after a short hover, or at once on keyboard focus, in the top layer beside the trigger, flips above it near the bottom of the screen, and stays open while the pointer crosses onto it. Leaving both closes it, Escape closes it at once, and touch screens never open it, so a tap follows the link. Splat the yielded attributes on the trigger. content: renders the card up front; src: loads it as HTML from your endpoint the first time it opens, from the page's own origin only, so a long list of triggers costs nothing until one is hovered, and a skeleton shows until then. The card is a preview: it is hidden from assistive technology and its links leave the tab order, so keep everything in it reachable from the page the link opens. Inside a paragraph, keep content: to phrasing elements such as spans.

<%= lc_hovercard src: card_person_path(person) do |card| %>
  <%= link_to person.name, person, **card %>
<% end %>

Search

lc_search renders a search trigger, a pill with the ⌘K hint that is a plain icon button on phones, and the full-screen search it opens. Attributes go to the trigger, which is what sits in your layout. Build results from lc_search_group and lc_search_result.

<%= lc_search label: "Search", src: search_path %>

<%# app/views/searches/show.html.erb, rendered without a layout for lc_search's requests %>
<%= lc_search_group "Projects" do %>
  <% @projects.each do |project| %>
    <%= lc_search_result project.name, project_path(project), detail: project.client, icon: "folder" %>
  <% end %>
<% end %>

With src:, each pause in typing requests src with the query in param (q by default) and shows the HTML the server answers; that endpoint is yours, as a Turbo Frame's would be. Without JavaScript the field submits the same GET, so a full search page still works. Without src:, the rows rendered in the block are filtered in the browser by their text and keywords:. To search another way, handle lc-search:query, call preventDefault() and fill event.detail.results with the same helpers' markup, cloned from a <template>; the docs search does this with MiniSearch.

The block also renders what shows before anything is typed. Arrow keys move through the results, Enter opens the first one, and choosing a result or pressing Escape closes search and returns focus. Groups without a visible result hide, a query with none shows the empty note, and a status region announces the count. empty: sets that note, with %{query} standing for the query, and prompt: adds a note for when nothing is typed and there is nothing to show. While src is answering, the panel is aria-busy and both notes wait, so they never flash before the results arrive. Pass shortcut: nil to drop the page shortcut, and id: when a page has two searches.

Keyboard

Every interactive component works from the keyboard without extra code:

Component Keys
Menu Arrow Down or Up on the button opens on the first or last item. Arrows move and wrap, Home and End jump, a letter jumps to the next item that starts with it, Enter or Space activates, Escape closes and returns focus.
Tabs Arrows along the tab list's orientation, Home and End. Automatic tabs select on focus; manual tabs on Enter or Space.
Toggle group One Tab stop. All four arrows move and select, wrapping, as native radios do; Left and Right follow the text direction.
Emoji picker Arrow Down from the search enters the grid, arrows move through it by row, Arrow Up from the top row returns to the search, and Enter in the search picks the best match. The grid is one Tab stop.
Dialogs, sheets, popovers, menus, tooltips Escape closes the topmost one and returns focus to what opened it; an open tooltip closes before the menu or dialog around it. Escape in a search field with text clears it first.

The focus ring follows how the person is moving. Focus that comes back from a closed dialog, sheet, menu or popover shows its ring only after Tab or an arrow key moved focus; Escape, Enter in a field and typing don't count, so a dialog opened with the mouse and closed with Escape leaves no ring on its button. A panel closed from inside, such as by choosing a menu item, returns focus to what opened it, and a dialog closed with nothing focused before it, as after a click in Safari, returns focus to the control that was pressed. A controller that moves focus back itself calls settleFocus() from lostcoords/ui/helpers/focus afterwards for the same rule. Hosts that skip base.css hide the ring on [data-lc-focus-quiet]:focus-visible.

The ring itself is the lc-focus-ring utility: two units of --ring hugging the element's own radius. base.css draws it on every focusable element, so a component never restates an outline. One whose ring belongs on another element applies the utility through a variant, as a linked list row does with has-[[data-slot=list-link]:focus-visible]:lc-focus-ring.

Page-wide shortcuts focus a field or press a button. Merge lc_shortcut_data into the element's data and show the keys with lc_kbd:

<%= lc_input type: :search, name: "q", aria: { label: "Search" }, data: lc_shortcut_data("mod+k") %>
<%= lc_button data: lc_shortcut_data("n", action: "projects#new") do %>
  New project <%= lc_kbd "n", aria: { hidden: true } %>
<% end %>

Keys are joined with +: mod is ⌘ on Apple platforms and Ctrl elsewhere, and ctrl, alt, shift and meta name the others. Separate alternatives with spaces. The element announces its keys through aria-keyshortcuts. Shortcuts without mod, ctrl or alt don't fire while typing in a field, only shortcuts inside an open modal dialog respond, and when two visible elements share keys the first wins and the console warns. lc_kbd renders the Ctrl form and switches to Apple symbols once JavaScript runs.

Custom widgets can use the same navigation: navigate(event, items, { orientation, wrap, typeahead }) from lostcoords/ui/helpers/roving_focus handles vertical, horizontal and grid layouts, right-to-left text, Home and End, and typeahead; rove(items, current) keeps a single Tab stop.

Layers

Overlays never need a z-index. Dialogs and sheets open as modal <dialog> elements; menus, popovers, pickers and tooltips move into the browser's top layer while they are open; toasts go in lc_toast_region, which does the same. The top layer paints above every z-index, overflow clip and stacking context on the page, so a sticky header, a transform or a glass backdrop-filter can't cover them. A modal dialog makes the rest of the page inert, so while one is open the toast region moves inside it and back when it closes. The region is the live region that announces its toasts; destructive toasts are alerts. Where the Popover API is missing overlays stay in place, ordered by --lc-z-popover, --lc-z-overlay and --lc-z-toast.

<%# In the layout, once %>
<%= lc_toast_region id: "toasts" do %>
  <% flash.each do |type, message| %><%= lc_toast message, tone: type == "alert" ? :destructive : :success %><% end %>
<% end %>

<%# From a controller or job %>
<%= turbo_stream.append "toasts" do %><%= lc_toast "Project saved." %><% end %>

The region sits at the bottom-end corner. placement: takes :bottom_end, :bottom_center, :top_end or :top_center, and mobile_placement: takes the same values below sm, as in lc_toast_region id: "toasts", placement: :bottom_center, mobile_placement: :top_center. The region keeps clear of the safe area; set --lc-toast-offset to move it further from the edges, or --lc-toast-offset-top and --lc-toast-offset-bottom for one edge, such as below a sticky header.

While a modal dialog or sheet is open the page behind it can't scroll: the body is pinned with position: fixed and marked data-modal-scroll-lock="true", so window.scrollY reads 0 until it closes. Scroll-driven chrome, such as a header that fills in once the page scrolls, should keep its state while that attribute is set; the body's --lc-scroll-lock-y holds the real offset.

Two in-page layers remain: z-sticky keeps app chrome such as a sticky header above content, and z-raised lifts an element over its neighbours. Put isolate on the main content area, so any z-index inside it stays below the chrome. Tailwind drops a z-* class it can't resolve without a warning, so use these two names, a number or z-(--a-defined-variable).

Copy feedback and motion

<%= lc_copy_button value: "https://example.com/invite" %>
<%= lc_copy_button "Copy invite link", value: invite_url, copied_label: "Link copied" %>
<%= lc_copy_button "Copy link", value: invite_url, icon_only: true, variant: :ghost %>
<%= lc_copy_button "Copy code", source: "code-snippet", reset_after: 2500 %>

Pass exactly one of value: (literal text) or source: (an element ID). The source is read at click time: inputs and textareas use their current value; other elements use their text content. Text is copied as supplied, including whitespace. Clipboard access requires HTTPS or localhost and browser permission.

After a successful copy, the button transitions to a check and "Copied", then resets after reset_after: milliseconds (2000 by default). Failure shows a retry icon and label with an accessible explanation. The button reserves space for all labels, preserves focus, and announces the outcome through a live region. Default labels are translated in English, Japanese and Spanish. Use label (the first argument), copied_label: and error_label: to customize visible text, and aria: { label: ... } for a contextual name. Normal button variants, sizes, classes, disabled state and attributes are supported.

The component emits bubbling lc-copy:copied (detail.text) and lc-copy:error (detail.error) events from its wrapper. Listen on an ancestor to connect application behavior.

<%= lc_code_block "puts 'Hello'", id: "ruby-example", language: :ruby %>
<%= lc_code_block source, id: "file-example", language: :ruby, title: "app/helpers/greeting_helper.rb" %>
<%= lc_code_block source, id: "long-example", language: :ruby, max_lines: 5 %>

Code blocks escape plain source, preserve whitespace, and include a floating icon-only copy button. The copy control appears on hover or keyboard focus and stays visible on touch devices and during copy feedback. Snippets have no header by default; use title: for a compact filename or heading. language: sets code metadata without adding a visible label. Snippets longer than max_lines: (10 by default) can expand and collapse; use max_lines: nil to show all lines. Copy failures expand clipped source for manual selection. Labels are translated in English, Japanese and Spanish. An optional block receives the raw source and can return highlighted markup from the app's syntax highlighter. For selective JavaScript registration, include both lc-code-block and lc-copy.

Buttons include hover and press feedback. Override --lc-motion-quick (140ms), --lc-motion-control (180ms), --lc-motion-feedback (160ms), --lc-press-scale (0.96) and --lc-ease-out in your theme or on a container. Reduced motion removes control movement and makes copy feedback immediate. Your application owns the pending, success and failure states of network actions such as saving a form.

Try the copy button · Motion reference

Icons

lc_icon renders Heroicons v2.2.0 SVGs. Variants are outline (the default), solid, mini and micro. Pass SVG attributes through options: and existing path attributes through path_options:.

<%= lc_icon "check", options: { class: "size-5" } %>
<%= lc_icon "check", variant: :mini, options: {
  class: "size-4", role: "img", aria: { label: "Complete", hidden: false }
} %>

Advanced style composition

Typography and layout

Heading level controls document structure independently of its visual size. Layout parents own the spacing between children, including fields. Inline <code> elements get a shared monospace style; <pre><code> blocks keep their block styling.

<%= lc_stack gap: :section do %>
  <%= lc_heading "Workspace", level: 1, size: :title %>
  <%= lc_section title: "Members" do %>
    <%= lc_card do %>
      <%= lc_stack gap: :related do %>
        <%= lc_heading "Design team", level: 3, size: :subheading %>
        <%= lc_text "Three people share this workspace.", tone: :muted %>
      <% end %>
    <% end %>
  <% end %>
<% end %>

Heading sizes are display, title, heading and subheading. Text sizes are body, small, label, caption and eyebrow, with default and muted tones. lc_text_class(size: :eyebrow, tone: :muted) styles a kicker or footer column label; under lang="ja" it keeps natural case and letter spacing. Pass trim: true to trim the text box. Stacks and inline groups take the spacing names from Foundations. lc_stack, lc_inline, lc_text and lc_card take as: to render a meaningful element, such as lc_stack(as: :ul), lc_text(as: :span) or lc_card(as: :section). lc_heading(as: :span) sets text in a heading role without adding a heading to the outline, such as a total in a summary row. lc_section leaves heading below its title and content between blocks. lc_split lays out a main column and an aside: one column on small screens, and from lg a flexible main beside an aside of aside: :sm (16rem), :md (20rem) or :lg (24rem). lc_columns(count: 2) flows groups, such as settings sections, into balanced columns from lg (count: 3 adds a third from xl) without breaking a group across two. lc_section_header is that heading row on its own, for a heading that needs more than a title, such as a lede under it. lc_container provides page, reading and form widths; only the page container adds gutters. Japanese headings inherit lang="ja" and use natural letter spacing.

Browse the foundations examples.

Reading content

For articles or rendered Markdown, enable Tailwind Typography in the host input:

@plugin "@tailwindcss/typography";

The standalone Tailwind CLI used by tailwindcss-rails includes this plugin. lc_prose supplies the host theme colours, a 65ch maximum width, 1.75 line height and proportional block spacing. Its block follows Rails' normal escaping rules; sanitise rendered user content before marking it safe.

<%= lc_prose do %>
  <h2>Share a workspace</h2>
  <p>Invite your team and keep your work together.</p>
  <div class="not-prose"><%= lc_button "Invite someone" %></div>
<% end %>

Override --lc-reading-size, --lc-reading-leading, --lc-reading-flow and --lc-reading-measure to tune a reading context. Use not-prose for embedded components.

Class helpers

Class helpers remain available for custom markup. The application owns its semantics and behavior. lc_glass_class supplies translucent surfaces; lc_tw merges utilities with the last class winning. lc_glass(shape:, thick:, as:) renders the surface as an element, such as lc_glass as: :label around a search field.

<nav class="<%= lc_glass_class(shape: :bar) %>" aria-label="Project navigation">
  <%= link_to "Overview", project_path(@project), class: lc_button_class(variant: :ghost) %>
</nav>

Generated by bin/rails lostcoords:ui:builders; bin/lint checks this list against the style helpers.

  • lc_avatar_badge_class(size: :md, control: false, extra: nil) (AvatarBadgeHelper)
  • lc_icon_badge_class(size: :md, shape: :square, tone: :neutral, extra: nil) (BadgeHelper)
  • lc_avatar_class(size: :md, ink: false, linked: false, extra: nil) (BadgeHelper)
  • lc_avatar_stack_class(compact: false, size: :md, overlap: :md, extra: nil) (BadgeHelper)
  • lc_avatar_stack_row_class(extra: nil) (BadgeHelper)
  • lc_badge_class(tone: :neutral, shape: :rounded, extra: nil) (BadgeHelper)
  • lc_toggle_class(active: false, ghost: false, size: :md, extra: nil) (BadgeHelper)
  • lc_button_class(variant: :primary, tone: :default, size: :md, block: false, extra: nil) (ButtonHelper)
  • lc_select_trigger_class(size: :md, block: false, extra: nil) (ButtonHelper)
  • lc_icon_button_class(shape: :circle, size: :md, icon_size: size, variant: :ghost, tone: :default, extra: nil) (ButtonHelper)
  • lc_card_class(interactive: false, padding: :md, extra: nil) (CardHelper)
  • lc_choice_label_class(card: false, extra: nil) (ChoiceHelper)
  • lc_checkbox_class(extra: nil) (ChoiceHelper)
  • lc_radio_class(extra: nil) (ChoiceHelper)
  • lc_switch_class(extra: nil) (ChoiceHelper)
  • lc_dialog_class(kind: :modal, size: nil, extra: nil) (DialogHelper)
  • lc_emoji_picker_groups (EmojiPickerHelper)
  • lc_emoji_picker_count (EmojiPickerHelper)
  • lc_emoji_picker_version (EmojiPickerHelper)
  • lc_emoji_picker_search_text(emoji) (EmojiPickerHelper)
  • lc_emoji_picker_search_name(emoji) (EmojiPickerHelper)
  • lc_emoji_picker_search_labels(emoji) (EmojiPickerHelper)
  • lc_emoji_picker_toneable?(emoji) (EmojiPickerHelper)
  • lc_alert_class(extra: nil) (FeedbackHelper)
  • lc_alert_icon(tone: :destructive) (FeedbackHelper)
  • lc_spinner_class(size: :md, extra: nil) (FeedbackHelper)
  • lc_skeleton_class(extra: nil) (FeedbackHelper)
  • lc_empty_state_class(extra: nil) (FeedbackHelper)
  • lc_file_drop_class(extra: nil) (FileDropHelper)
  • lc_toggle_group_class(layout: :inline, scroll: false, extra: nil) (FormHelper)
  • lc_toggle_group_item_class(active: false, layout: :inline, extra: nil) (FormHelper)
  • lc_input_class(size: :md, plain: false, extra: nil) (FormHelper)
  • lc_select_class(size: :md, extra: nil) (FormHelper)
  • lc_textarea_class(extra: nil) (FormHelper)
  • lc_field_class(size: :md, extra: nil) (FormHelper)
  • lc_field_label_class(size: :md, extra: nil) (FormHelper)
  • lc_glass_class(shape: :bar, thick: false, extra: nil) (GlassHelper)
  • lc_stack_class(gap: :content, extra: nil) (LayoutHelper)
  • lc_inline_class(gap: :related, extra: nil) (LayoutHelper)
  • lc_container_class(size: :page, extra: nil) (LayoutHelper)
  • lc_split_class(aside: :md, extra: nil) (LayoutHelper)
  • lc_columns_class(count: 2, extra: nil) (LayoutHelper)
  • lc_section_header_class(extra: nil) (LayoutHelper)
  • lc_popover_class(align: :end, side: :bottom, extra: nil) (MenuHelper)
  • lc_menu_popover_class(align: :end, side: :bottom, extra: nil) (MenuHelper)
  • lc_menu_option_class(tone: :default, extra: nil) (MenuHelper)
  • lc_link_class(tone: :inherit, extra: nil) (NavigationHelper)
  • lc_nav_link_class(compact: false, layout: :column, extra: nil) (NavigationHelper)
  • lc_prose_class(extra: nil) (ReadingHelper)
  • lc_table_class(extra: nil) (TableHelper)
  • lc_tw(*classes) (TailwindHelper)
  • lc_heading_class(size: :heading, trim: false, extra: nil) (TypographyHelper)
  • lc_text_class(size: :body, tone: :default, trim: false, extra: nil) (TypographyHelper)
  • lc_kbd_class(extra: nil) (TypographyHelper)
  • lc_shortcut_data(keys, data = {}) (TypographyHelper)

Blocks

Browse the blocks for complete layouts assembled from the existing components. Each block has an interactive preview and the ERB, CSS and JavaScript that render it. Copy the files into your app and adapt the content, routes and actions.

Blocks live in the docs app. They add no rendering helpers or installable block APIs to the gem.

Docs

The docs app lives in test/dummy. Run parcela up --detach and open https://ui.localhost. Parcela starts Rails (with live reload through Hotwire Spark) and the Tailwind watcher. parcela down stops this environment.

bin/rails kiln:build exports every docs route to docs/, which Cloudflare serves at ui.lostcoords.com, with Kiln: pages, blocks, the token reference, the machine-readable API and assets. Param sources for the component and block pages live in test/dummy/config/kiln.rb, and a route without one fails the build. bin/rails kiln:serve serves the export the way Cloudflare does. CI runs bin/rails kiln:build and fails when docs/ changes, and checks that every public rendering helper has a runnable example.

Development

bundle install && npm ci
bin/rails server            # the dummy app in test/dummy
bin/rails tailwindcss:build
bin/test
bin/lint
npx playwright install chromium   # once
bin/browser-test            # every suite in test/browser, headless, against its own docs server
bin/browser-test sheets     # one suite; BASE_URL=https://ui.localhost reuses a running server

The icon catalog and its MIT license live in vendor/heroicons. Regenerate them from the pinned upstream archive with ruby bin/update-icons.

About

Lost Coordinates UI: Rails engine with Tailwind class builders, Hotwire overlays and a component showcase

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages