Installation

LesliView packages ViewComponent classes, Rails form builders, layouts, charts, widgets, and domain-oriented views for the Lesli presentation layer.

Standard Lesli applications

Lesli installs LesliView and LesliAssets automatically. Verify the registered gems from the host application:

bin/rails lesli:status

Other Rails applications

Add the component and asset gems:

bundle add lesli_view
bundle add lesli_assets

LesliView depends on ViewComponent and Lexxy at runtime. The host application must also load the styles, Material Symbols, JavaScript, and other frontend resources distributed by LesliAssets. A component can render without those resources, but it will not have its intended presentation or interactive behavior.

Load the shared stylesheet before the component stylesheet in the layout's <head>:

<%= stylesheet_link_tag "lesli_assets/application", "data-turbo-track": "reload" %>
<%= stylesheet_link_tag "lesli_view/view", "data-turbo-track": "reload" %>

LesliAssets defines the global Lesli palette and the complete Tailwind theme, including spacing, typography, radii, and animations. LesliView uses @reference to compile component styles without emitting those variables again. The standard Lesli layout already loads these stylesheets in this order. Public layouts can load lesli_assets/public instead of lesli_assets/application; both provide the complete theme. A custom host must update LesliAssets alongside LesliView when adopting this centralized theme.

Verify the installation in an ERB view:

<%= render LesliView::Elements::Button.new("Continue", url: root_path) %>

Use the fully qualified constants shown in these guides. Most components accept a block through ViewComponent, while components with named slots document those slots explicitly.

Component styles

LesliView renders semantic classes such as lesli-button, lesli-header, and lesli-panel-dialog. Component stylesheets use unprefixed Tailwind utilities inside @apply, including responsive and interaction variants:

@layer components {
    .lesli-panel-dialog {
        @apply fixed w-full bg-white sm:max-w-2xl lg:max-w-3xl;
    }
}

The entrypoint imports each component stylesheet explicitly and disables utility discovery. It emits component rules, not global utility selectors such as .flex or .text-sm. Alpine bindings and transitions also use component classes. Keep modifiers scoped to their component; a Ruby class or sidecar directory alone does not isolate CSS.

Theme values remain global in LesliAssets. LesliView references that theme at build time and compiles independently into lesli_view/view.css.

Component file structure

Keep the Ruby class next to a directory containing its template and stylesheet:

lib/lesli_view/
    partials/
        error.rb
        error/
            error.html.erb
            error.css

This convention applies to components, elements, items, layout, partials, widgets and charts. Register new component CSS with an explicit import in source/tailwind/view.css.

Only create a directory when a component has presentation files. For example, Charts::Bar and Charts::Line share General's template and stylesheet.

Forms keep their current Ruby files and shared forms/form.css. Do not create individual directories or duplicate styles for builders and field helpers.

The files under app/assets/stylesheets/lesli_view/ are generated output. Edit component CSS and rebuild instead of editing the compiled stylesheet.

Upgrading

Publish templates and compiled CSS together. Use component classes or data attributes for JavaScript selectors. Do not add a Tailwind package prefix.

Engines may keep passing their own classes through css_class:, class_name:, or form options. Those classes must be compiled by the calling engine, as must styles used by content supplied in component blocks. Engines compile their own unprefixed Tailwind utilities against the shared LesliAssets theme.

Load lesli_view/view in public authentication layouts as well. Engines should load this stylesheet instead of recompiling component CSS. The standard Lesli Devise layout follows this arrangement.

The documentation website continues to use Bulma for its previews and layout.

 Edit this page

Last Update: 2026/11/18