Skip to content
Components

Documentation layout

A sidebar, page content and an "On this page" list, with a collapsible menu on phones.

Open preview ↗

Interact with the example above, or open it in a full window.

After setting up the library, copy the example files into your app and adapt the content. These are composition references, with no block API to install or import.

lc_docs_shell takes the sidebar as navigation: and an lc_toc as contents:, with the page as its block. This documentation site uses it for every guide and component page.

Mark the current page with current: true so the sidebar sets aria-current. The contents list appears from the xl breakpoint and marks the section you have scrolled to.

The preview renders this ERB and loads these styles and interactions.

app/views/shared/_docs_shell.html.erb

<% navigation = lc_nav_list label: "Guides" do |nav| %>
  <%= nav.group "Getting started" do %>
    <%= nav.link "Introduction", "#introduction", current: true %>
    <%= nav.link "Install", "#install" %>
  <% end %>
  <%= nav.group "Guides" do %>
    <%= nav.link "Accounts", "#accounts" %>
    <%= nav.link "Billing", "#billing" %>
    <%= nav.link "Webhooks", "#webhooks" %>
  <% end %>
<% end %>
<% contents = lc_toc do |toc| %>
  <%= toc.link "Requirements", "#requirements" %>
  <%= toc.link "API keys", "#keys", indent: true %>
  <%= toc.link "Next steps", "#next" %>
<% end %>
<%= lc_docs_shell navigation:, contents:, menu_label: "Guides" do %>
  <%= lc_stack gap: :section do %>
    <header id="introduction" class="<%= lc_stack_class(gap: :heading) %>">
      <%= lc_breadcrumb [ [ "Docs", "#introduction" ], "Introduction" ] %>
      <%= lc_heading "Introduction", level: 1, size: :title %>
      <%= lc_text "Everything you need to connect your workspace.", tone: :muted %>
    </header>
    <%= lc_section title: "Requirements", id: "requirements", anchor: true do %>
      <%= lc_text "An account with owner access and an API key from your settings.", size: :small, tone: :muted %>
      <%= lc_heading "API keys", level: 3, size: :subheading, id: "keys", anchor: true %>
      <%= lc_text "Create a key for each environment and keep it out of your repository.", size: :small, tone: :muted %>
    <% end %>
    <%= lc_section title: "Next steps", id: "next", anchor: true do %>
      <%= lc_text do %>Read the <%= lc_link "install guide", "#install" %> to make your first request.<% end %>
    <% end %>
    <%= lc_pager next: [ "Install", "#install" ] %>
  <% end %>
<% end %>
← All blocks