App sidebar
The left column of an app: switcher, links, folding sections, an unread count on Inbox.
import { AppSidebar } from "@forgeron/ui";Tasks
import { Folder01Icon, InboxIcon, Layers01Icon, Tick01Icon, UserCircleIcon } from "@forgeron/icons";
import { AppSidebar } from "@forgeron/ui";
import { useState } from "react";
export default function Default() {
const [current, setCurrent] = useState("#/inbox");
return (
<div style={{ width: 220, height: 230 }}>
<AppSidebar
app={{ name: "Tasks", icon: Tick01Icon }}
current={current}
onNavigate={(href, event) => {
event.preventDefault();
setCurrent(href);
}}
items={[
{ href: "#/inbox", label: "Inbox", icon: InboxIcon, count: 4 },
{ href: "#/my", label: "My issues", icon: UserCircleIcon },
]}
sections={[
{
label: "Workspace",
items: [
{ href: "#/projects", label: "Projects", icon: Folder01Icon },
{ href: "#/views", label: "Views", icon: Layers01Icon },
],
},
]}
/>
</div>
);
}import {
CheckmarkSquare01Icon,
DashboardSquare01Icon,
Edit02Icon,
Folder01Icon,
HelpCircleIcon,
InboxIcon,
Layers01Icon,
MoreHorizontalIcon,
Note01Icon,
RefreshIcon,
Search01Icon,
Tick01Icon,
UserAdd01Icon,
UserCircleIcon,
UserGroupIcon,
} from "@forgeron/icons";
import { AppSidebar, Avatar, IconButton } from "@forgeron/ui";
import { useState } from "react";
const team = (key: string) => [
{ href: `#/team/${key}/issues`, label: "Issues", icon: CheckmarkSquare01Icon },
{ href: `#/team/${key}/projects`, label: "Projects", icon: Folder01Icon },
{ href: `#/team/${key}/views`, label: "Views", icon: Layers01Icon },
];
export default function Tasks() {
const [current, setCurrent] = useState("#/team/OPS/issues");
return (
<div style={{ width: 260, height: 520, border: "1px solid var(--line)" }}>
<AppSidebar
app={{ name: "Tasks", icon: Tick01Icon }}
appMenu={[
{ heading: "Atelier Moreau" },
{ id: "console", label: "Console", icon: DashboardSquare01Icon },
{ id: "tasks", label: "Tasks", icon: Tick01Icon, checked: true },
{ id: "crm", label: "CRM", icon: UserGroupIcon },
{ id: "notes", label: "Notes", icon: Note01Icon },
]}
onAppMenuSelect={() => {}}
actions={
<>
<IconButton icon={Search01Icon} label="Search" size="sm" />
<IconButton icon={Edit02Icon} label="New issue" size="sm" variant="boxed" />
</>
}
current={current}
onNavigate={(href, event) => {
event.preventDefault();
setCurrent(href);
}}
items={[
{ href: "#/inbox", label: "Inbox", icon: InboxIcon, count: 4 },
{ href: "#/my", label: "My issues", icon: UserCircleIcon },
]}
sections={[
{
label: "Workspace",
items: [
{ href: "#/projects", label: "Projects", icon: Folder01Icon },
{ href: "#/views", label: "Views", icon: Layers01Icon },
{ href: "#/more", label: "More", icon: MoreHorizontalIcon },
],
},
{
label: "Your teams",
items: [
{ label: "Operations", initial: "O", items: team("OPS") },
{ label: "Sales", initial: "S", items: team("SAL"), defaultOpen: false },
],
},
{
label: "Try",
defaultOpen: false,
items: [
{ href: "#/invite", label: "Invite people", icon: UserAdd01Icon },
{ href: "#/cycles", label: "Cycles", icon: RefreshIcon },
],
},
]}
footer={
<>
<IconButton
icon={HelpCircleIcon}
label="Keyboard shortcuts"
size="sm"
variant="boxed"
/>
<Avatar name="Camille Roy" />
</>
}
/>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
app | { name, icon } | — | The app on top: its tile and name. |
items | AppSidebarLink[] | — | The primary links: { href, label, icon?, initial?, count?, items? }. count: unread only, never a total. |
sections | { label, items, collapsible?, defaultOpen? }[] | — | Groups under a mono heading that folds them. A link with items folds too. |
current | string | — | The href shown: aria-current and the bar. |
onNavigate | (href, event) => void | — | On a link's click; preventDefault for client routing. |
appMenu / onAppMenuSelect | ActionMenuEntry[] / (id) => void | — | The switcher opens these as a menu. |
actions | ReactNode | — | Icon buttons after the switcher. |
footer | ReactNode | — | Help, the viewer's avatar. |
label | string | `${app.name} navigation` | Names the nav landmark. |