App
App Rail.
A narrow vertical workspace nav: icon over a mono label, the active item marked with an orange left border, with pinned items at the bottom.
WorkspaceMap.
"use client";
import * as React from "react";
import {
BoxIcon,
CodeIcon,
GridIcon,
HammerIcon,
ListChecksIcon,
MapIcon,
SettingsIcon,
SquareTerminalIcon,
} from "lucide-react";
import { AppRail, AppRailContent, AppRailFooter, AppRailItem } from "@/components/ui/app-rail";
const items = [
{ label: "Map", icon: MapIcon },
{ label: "Programs", icon: CodeIcon },
{ label: "Jobs", icon: ListChecksIcon },
{ label: "Build", icon: HammerIcon },
{ label: "Storage", icon: BoxIcon },
{ label: "Craft", icon: GridIcon },
{ label: "Console", icon: SquareTerminalIcon },
];
export default function AppRailDemo() {
const [active, setActive] = React.useState("Map");
return (
<div className="flex h-[520px] w-full max-w-md overflow-hidden rounded-lg border bg-background">
<AppRail aria-label="Workspaces">
<AppRailContent>
{items.map((item) => (
<AppRailItem key={item.label} isActive={active === item.label} onClick={() => setActive(item.label)}>
<item.icon />
<span>{item.label}</span>
</AppRailItem>
))}
</AppRailContent>
<AppRailFooter>
<AppRailItem isActive={active === "Settings"} onClick={() => setActive("Settings")}>
<SettingsIcon />
<span>Settings</span>
</AppRailItem>
</AppRailFooter>
</AppRail>
<div className="flex flex-1 flex-col gap-2 bg-grid p-5">
<span className="font-mono text-[10px] tracking-[0.2em] text-success uppercase">Workspace</span>
<span className="font-display text-2xl font-medium tracking-tight">
{active}
<span className="text-primary">.</span>
</span>
</div>
</div>
);
}Installation#
With the CLI
$npx lanterncn add app-railThis also installs the Lantern theme and any Lantern UI components it depends on. The shadcn CLI works directly too: npx shadcn@latest add httptim/lantern-ui/app-rail. See Installation if your project is not set up yet.
Manually
Install the dependencies
npm install radix-uiCopy the source into your project
components/ui/app-rail.tsximport * as React from "react"; import { Slot } from "radix-ui"; import { cn } from "@/lib/utils"; /** * Vertical workspace navigation: icon over a mono label, the active item marked with an * orange left border. Put the main items in AppRailContent and pinned items in AppRailFooter. * Pair it with BottomTabBar on phones. */ function AppRail({ className, ...props }: React.ComponentProps<"nav">) { return ( <nav data-slot="app-rail" className={cn("flex h-full w-[4.5rem] shrink-0 flex-col border-r bg-card py-2", className)} {...props} /> ); } function AppRailContent({ className, ...props }: React.ComponentProps<"ul">) { return ( <ul data-slot="app-rail-content" className={cn("flex min-h-0 flex-1 flex-col items-stretch gap-0.5 overflow-y-auto [scrollbar-width:none]", className)} {...props} /> ); } function AppRailFooter({ className, ...props }: React.ComponentProps<"ul">) { return ( <ul data-slot="app-rail-footer" className={cn("mt-auto flex flex-col items-stretch gap-0.5 pt-2", className)} {...props} /> ); } /** * One rail link. Renders a button, or pass asChild to render your own link. * Put an icon and a short label inside. */ function AppRailItem({ className, isActive = false, asChild = false, type, ...props }: React.ComponentProps<"button"> & { isActive?: boolean; asChild?: boolean }) { const Comp = asChild ? Slot.Root : "button"; return ( <li className="flex"> <Comp data-slot="app-rail-item" type={asChild ? type : (type ?? "button")} data-active={isActive || undefined} aria-current={isActive ? "page" : undefined} className={cn( "relative flex w-full cursor-pointer flex-col items-center gap-1 border-l-2 border-transparent px-1 py-2.5 text-muted-foreground transition-colors outline-none", "hover:bg-secondary/60 hover:text-foreground focus-visible:bg-secondary focus-visible:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-inset", "data-[active]:border-primary data-[active]:bg-secondary data-[active]:text-primary", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-5", "[&>span]:max-w-full [&>span]:truncate [&>span]:font-mono [&>span]:text-[9px] [&>span]:leading-none [&>span]:tracking-[0.08em] [&>span]:uppercase", className, )} {...props} /> </li> ); } export { AppRail, AppRailContent, AppRailFooter, AppRailItem };Update the import paths to match your project
The source imports
cnfrom@/lib/utils.
Usage#
import { AppRail, AppRailContent, AppRailFooter, AppRailItem } from "@/components/ui/app-rail";<AppRail aria-label="Workspaces">
<AppRailContent>
<AppRailItem isActive>
<MapIcon />
<span>Map</span>
</AppRailItem>
</AppRailContent>
<AppRailFooter>
<AppRailItem asChild>
<a href="/settings"><SettingsIcon /><span>Settings</span></a>
</AppRailItem>
</AppRailFooter>
</AppRail>The rail is 72px wide and fills its parent's height. Items are buttons; pass asChild to render a link. The active item gets aria-current="page". Keep labels to one short word; longer ones truncate.
On phones, hide the rail (className="hidden md:flex") and render the same items in a Bottom Tab Bar. The App Shell block does this.