Search the documentation

Type to search page titles, component names and descriptions.

    Layout

    AppNavigation

    One navigation model: a sidebar on desktop, a drawer on a phone.

    import { AppNavigation, NavigationDrawer, NavigationGroup, NavigationHeader, NavigationItem, NavigationTrigger, NavigationToggle } from 'faifo-design'

    AppNavigation renders the same groups and items as a persistent sidebar on wide screens and as an accessible drawer on narrow ones. The parts (NavigationHeader, NavigationGroup, NavigationItem, NavigationTrigger, NavigationToggle, NavigationDrawer) are exported for shells that compose their own.

    #When to use

    • Pass one model for every breakpoint. Do not maintain a second menu for mobile.
    • The active item is a fact of the URL; mark it on the server.
    • Counts beside items are data the host provides, already filtered by what the reader may see.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Responsive application navigation

    One navigation model becomes a persistent desktop sidebar and an accessible mobile drawer.

    Acme · Main branch

    Operations overview

    Open orders

    148

    12 need attention

    Ready to invoice

    91

    Updated just now

    Show codeHide code
    import { JSXChild, TemplateResult } from '@ketvietlab/ketjs-view'
    import { AppBrand, AppNavigation, AppShell, AppTopbar, Grid, Icon, Metric, NavigationToggle, Page, Progress, Stack } from 'faifo-design'
    // exampleApplications: a catalogue fixture, packages/faifo-design/src/catalogue/application-switcher.ts
    
    type DemoLayout = 'collection' | 'record' | 'flow' | 'canvas'
    
    const demoNavItems = (active: DemoLayout) => [
      {
        label: 'Collection',
        href: '#app-shell',
        leading: <Icon name="table" />,
        active: active === 'collection',
        count: 148,
      },
      { label: 'Record', href: '#record-page', leading: <Icon name="file-text" />, active: active === 'record' },
      {
        label: 'Flow',
        href: '#workspace-flow',
        leading: <Icon name="git-branch" />,
        active: active === 'flow',
        count: 7,
      },
      {
        label: 'Canvas',
        href: '#workspace-canvas',
        leading: <Icon name="layout-grid" />,
        active: active === 'canvas',
      },
    ]
    
    const DemoSidebar = (props: {
      id: string
      active: DemoLayout
      externalTrigger?: boolean
    }): TemplateResult => (
      <AppNavigation
        id={`demo-navigation-${props.id}`}
        externalTrigger={props.externalTrigger}
        label="Faifo workspace"
        identity={<AppBrand label="Faifo" href="#app-shell" />}
        context="Operations workspace"
        menuLabel="Workspace menu"
        tools={{
          searchLabel: 'Search menu',
          searchPlaceholder: 'Find a function…',
          emptyLabel: 'No matching function.',
          collapseLabel: 'Collapse menu',
        }}
        groups={[
          {
            id: `demo-primary-${props.active}`,
            label: 'Workspace',
            items: demoNavItems(props.active).map((item) => ({
              ...item,
              id: `${props.active}-${item.href.slice(1)}`,
            })),
          },
          {
            id: `demo-manage-${props.active}`,
            label: 'Manage',
            exclusive: false,
            items: [
              {
                id: `${props.active}-settings`,
                label: 'Settings',
                href: '#app-navigation',
                leading: <Icon name="settings" />,
              },
              {
                id: `${props.active}-reports`,
                label: 'Reports',
                expanded: true,
                leading: <Icon name="layout-dashboard" />,
                children: [
                  { id: `${props.active}-sales-report`, label: 'Sales', href: '#data-table', count: 7 },
                  {
                    id: `${props.active}-stock-report`,
                    label: 'Inventory',
                    href: '#metric',
                    leading: <Icon name="inbox" />,
                  },
                  {
                    id: `${props.active}-report-settings`,
                    label: 'Cấu hình',
                    expanded: true,
                    children: [
                      { id: `${props.active}-terms`, label: 'Điều khoản thanh toán', href: '#navigation-terms' },
                      {
                        id: `${props.active}-long-label`,
                        label: 'Phương thức thanh toán dành cho nhà cung cấp quốc tế',
                        href: '#navigation-long',
                      },
                    ],
                  },
                ],
              },
            ],
          },
        ]}
        footer="Signed in · Duy Kieu"
      />
    )
    
    const DemoRail = (props: {
      title: string
      detail: string
      progress?: number
      items?: readonly JSXChild[]
    }): TemplateResult => (
      <div data-ui="shell-demo-rail">
        <p data-ui="catalogue-kicker">Context</p>
        <strong>{props.title}</strong>
        <p>{props.detail}</p>
        {props.progress !== undefined && <Progress label={props.title} value={props.progress} />}
        {props.items !== undefined && <Stack gap="compact" items={props.items} />}
      </div>
    )
    
    const DemoShell = (props: {
      id: string
      active: DemoLayout
      main: JSXChild
      railTitle?: string
      railDetail?: string
      railProgress?: number
      railItems?: readonly JSXChild[]
    }): TemplateResult => (
      <AppShell
        applications={{
          ...exampleApplications,
          ...(exampleApplications.settings
            ? { settings: { ...exampleApplications.settings, id: `${props.id}-settings` } }
            : {}),
          items: [
            ...exampleApplications.items,
            { id: 'phone', label: 'Phone', icon: 'phone', unavailableLabel: 'Coming soon' },
            { id: 'chat', label: 'Chat', icon: 'message-circle', unavailableLabel: 'Coming soon' },
          ],
        }}
        mode="embedded"
        location={
          <AppTopbar
            location={<span>Acme · Main branch</span>}
            navigation={
              <NavigationToggle controls={`demo-navigation-${props.id}-drawer`} label="Open navigation" />
            }
            search={{
              id: `demo-global-search-${props.id}`,
              action: '#app-shell',
              triggerLabel: 'Search everywhere',
              closeLabel: 'Close',
              label: 'Global search',
              placeholder: 'Search…',
              submitLabel: 'Search',
            }}
          />
        }
        sidebar={<DemoSidebar id={props.id} active={props.active} />}
        main={props.main}
        rightRail={
          props.railTitle !== undefined ? (
            <DemoRail
              title={props.railTitle}
              detail={props.railDetail ?? ''}
              progress={props.railProgress}
              items={props.railItems}
            />
          ) : undefined
        }
      />
    )
    
    export const Example = () => (
      <DemoShell
        id="app-navigation"
        active="collection"
        main={
          <Page
            title="Operations overview"
            body={
              <Grid
                columns={2}
                items={[
                  <Metric label="Open orders" value="148" detail="12 need attention" />,
                  <Metric label="Ready to invoice" value="91" detail="Updated just now" />,
                ]}
              />
            }
          />
        }
      />
    )

    #Navigation in a sidebar island slot

    A single wrapper fills the sidebar; the navigation owns its internal scrolling.

    Invoices

    The sidebar slot remains visible through its wrapper.
    Show codeHide code
    import { AppNavigation, AppShell, Surface } from 'faifo-design'
    // exampleApplications: a catalogue fixture, packages/faifo-design/src/catalogue/application-switcher.ts
    
    export const Example = () => (
      <AppShell
        applications={exampleApplications}
        mode="embedded"
        sidebar={
          <div>
            <AppNavigation
              id="wrapped-nav"
              label="Navigation"
              groups={[
                {
                  id: 'work',
                  label: 'Work',
                  items: [{ id: 'invoices', label: 'Invoices', href: '#invoices' }],
                },
              ]}
            />
          </div>
        }
        main={<Surface title="Invoices" body="The sidebar slot remains visible through its wrapper." />}
      />
    )

    #Contract

    AppShell gives its sidebar's only child the available block size, including a disposable island wrapper. Navigation keeps its viewport geometry and internal scrolling; consumers do not patch sidebar descendants. Producer CSS check/mutation and Account browser geometry cover this contract. Account's breadcrumb-free canvas is an explicit user choice and still exposes a separate list-return link.

    Record runtime exposes draftScope (record / dialog) to namespace input IDs by owning layer. Route dialog metadata is present on both layers and must not determine control IDs. A refused submit focuses the first invalid control after rendering the retained draft.

    Button and LinkButton accept optional truncateLabel for single-line record values inside constrained layouts. The Action owns the shrink boundary and a full-label tooltip; its public Text owns the ellipsis. Keep the nested Text when updating the label at runtime, and update the tooltip to the complete value. Default actions continue to wrap. See the long-label catalogue specimen and test/design-system-action-truncate.test.tsx.

    Button.logo={{src}} opts into a named brand choice. It replaces the visible label with an 80×24 contained image on a 112×48 minimum stage, keeps label as the accessible name/tooltip, and shows a check icon when pressed. Consumers own selection and ordering; the public component owns geometry, frame, focus and original brand colours on white in both themes. Ordinary controls are unchanged. See test/design-system-logo-button.test.ts and the Button specimen.

    ModalSheet.size="workspace" fills the available viewport width inside the desktop overlay margin. It preserves the existing fullscreen phone behavior, native close route, focus return and height="fixed" bands. Layer clipping prevents focus/fragment navigation from scrolling the title or footer away; the body retains its scroll. See test/design-system-workspace-modal.test.ts.

    Menu label entries expose a stable ${menuId}-${entryId}-label ID and optional hidden state. A filtered menu can toggle its empty message inside the owned panel without moving unrelated page content into the popup. The consumer owns search results and live announcements; the Menu owns the label's spacing and typography. See test/design-system-menu-label.test.tsx.

    Menu choices and headings wrap long words within the panel. The shared runtime measures the trigger and enclosing scroll regions, keeps the popup inside their visible bounds, and opens above when more room is available. Resize updates the measurement; closing/disposal clears it. The native disclosure remains available without JavaScript. See test/design-system-menu-fit.test.ts.

    Menu takes triggerAppearance="plain" when its trigger content draws the face itself, such as an avatar or a tile matching the plain tiles beside it. The trigger keeps its name, disclosure semantics, focus ring and panel but drops the button frame, padding and fill, also at size="compact". Style the trigger content, never [data-ui="menu-trigger"]. See test/design-system-menu-trigger.test.tsx.

    Keyboard navigation skips hidden and disabled Menu choices after filtering. A disabled trigger blocks activation and navigation keys while preserving Tab and Escape. See test/design-system-menu-keyboard.test.ts.

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #AppNavigationComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    labelrequired–string–
    identity–JSXChild–
    externalTriggerA topbar may provide NavigationToggle while this component owns the drawer.boolean–
    groupsrequired–readonly NavigationGroupData[]–
    context–JSXChild–
    supplementary–JSXChild–
    footer–JSXChild–
    navigationSlot–string–
    menuLabel–string'Menu'
    closeLabel–string'Close navigation'
    open–boolean–
    tools–NavigationToolsProps–

    #NavigationDrawerComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    labelrequired–string–
    identity–JSXChild–
    groupsrequired–readonly NavigationGroupData[]–
    context–JSXChild–
    supplementary–JSXChild–
    footer–JSXChild–
    navigationSlot–string–
    closeLabelrequired–string–
    tools–NavigationToolsProps–

    #NavigationGroupComponent

    PropertyDescriptionTypeDefault
    exclusiveFalse allows multiple branches to remain open, including nested branches.boolean–
    idrequired–string–
    label–string–
    itemsrequired–readonly NavigationItemData[]–
    caretBranches without their own leading icon show a caret in the leading column that turns when the branch opens. Suits long lists of collapsed sections, such as API references.boolean–
    branchGroup–string–

    #NavigationHeaderComponent

    PropertyDescriptionTypeDefault
    identity–JSXChild–
    context–JSXChild–
    closeLabelrequired–string–
    searchId–string–
    controls–string–
    tools–NavigationToolsProps–

    #NavigationItemComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    labelrequired–string–
    leading–JSXChild–
    description–string–
    count–number–
    href–string–
    active–boolean–
    children–never–
    expanded–never–

    #NavigationTriggerComponent

    PropertyDescriptionTypeDefault
    controlsrequired–string–
    labelrequired–string–
    identity–JSXChild–
    open–boolean–

    #NavigationToggleComponent

    PropertyDescriptionTypeDefault
    controlsrequired–string–
    labelrequired–string–

    #Types

    #AppNavigationProps

    The properties of AppNavigation, listed above.

    #NavigationToolsProps

    PropertyDescriptionTypeDefault
    searchLabelrequired–string–
    searchPlaceholderrequired–string–
    emptyLabelrequired–string–
    collapseLabelrequired–string–

    #NavigationGroupData

    PropertyDescriptionTypeDefault
    exclusiveFalse allows multiple branches to remain open, including nested branches.boolean–
    idrequired–string–
    label–string–
    itemsrequired–readonly NavigationItemData[]–
    caretBranches without their own leading icon show a caret in the leading column that turns when the branch opens. Suits long lists of collapsed sections, such as API references.boolean–

    #NavigationItemData

    The properties of NavigationItem, listed above.

    #Hooks

    The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.

    • app-navigation
    • navigation-trigger
    • navigation-toggle
    • navigation-trigger-icon
    • navigation-trigger-identity
    • navigation-trigger-label
    • navigation-layer
    • navigation-backdrop
    • navigation-drawer
    • navigation-header
    • navigation-identity
    • navigation-context
    • navigation-close
    • navigation-groups
    • navigation-group
    • navigation-group-label
    • navigation-items
    • navigation-supplementary
    • navigation-item
    • navigation-branch
    • navigation-branch-trigger
    • navigation-children
    • navigation-item-leading
    • navigation-item-copy
    • navigation-item-label
    • navigation-item-description
    • navigation-item-count
    • navigation-footer
    • navigation-tools
    • navigation-search-toggle
    • navigation-search
    • navigation-search-input
    • navigation-search-empty
    • navigation-collapse