Search the documentation

Type to search page titles, component names and descriptions.

    Layout

    AppShell

    The frame of an application: rail, top bar, navigation and main column.

    import { AppBrand, AppSwitcher, AppSwitcherHelp, AppShell, AppTopbar } from 'faifo-design'

    AppShell places the application switcher, the top bar, the navigation and the main column, and keeps them in place while a screen changes. AppTopbar carries the application identity and the search launcher, AppBrand the mark, and AppSwitcher the persistent rail between applications.

    #When to use

    • Render the shell once per document and let screens replace the main column.
    • The host supplies destinations and translated names; the shell performs no permission check of its own.
    • A single application without a suite rail uses the same shell with a full-width top bar.

    #Examples

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

    #Collection shell

    A full list workspace with sidebar navigation, URL-owned list chrome and selectable rows.

    Acme · Main branch
    Sales / Sales orders

    Sales orders

    Filters
    1 selectedClear

    Order list

    OrderCustomerTotalState
    SO-1042Công ty Ánh Dương18.450.000 ₫Ready
    SO-1041Khách sạn Mùa Hạ6.800.000 ₫Review
    SO-1039Nguyễn Minh Châu2.150.000 ₫Blocked
    Show codeHide code
    import { JSXChild, TemplateResult } from '@ketvietlab/ketjs-view'
    import { AppBrand, AppNavigation, AppShell, AppTopbar, Badge, BulkActions, Button, DataTable, Icon, ListChrome, ListPage, NavigationToggle, Progress, Stack } from 'faifo-design'
    // exampleApplications: a catalogue fixture, packages/faifo-design/src/catalogue/application-switcher.ts
    
    type OrderRow = {
      id: string
      customer: string
      total: string
      state: 'Ready' | 'Review' | 'Blocked'
    }
    
    const orders: OrderRow[] = [
      { id: 'SO-1042', customer: 'Công ty Ánh Dương', total: '18.450.000 ₫', state: 'Ready' },
      { id: 'SO-1041', customer: 'Khách sạn Mùa Hạ', total: '6.800.000 ₫', state: 'Review' },
      { id: 'SO-1039', customer: 'Nguyễn Minh Châu', total: '2.150.000 ₫', state: 'Blocked' },
    ]
    
    const toneOf = (state: OrderRow['state']) =>
      state === 'Ready' ? ('positive' as const) : state === 'Review' ? ('warning' as const) : ('danger' as const)
    
    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
        }
      />
    )
    
    const OrdersTable = (props: { grouped?: boolean; title?: string } = {}): TemplateResult => (
      <DataTable
        title={props.title}
        rows={props.grouped ? ([] as OrderRow[]) : orders}
        id={(row) => row.id}
        rowHref={(row) => `#${row.id}`}
        responsive="stack"
        selection={{ selectedIds: ['SO-1042'] }}
        groups={
          props.grouped
            ? [
                {
                  id: 'ready',
                  label: 'Ready to invoice',
                  count: 2,
                  rows: orders.slice(0, 2),
                  pager: { label: '2 shown in Ready', nextHref: '#data-table' },
                },
                {
                  id: 'blocked',
                  label: 'Needs decision',
                  count: 1,
                  rows: orders.slice(2),
                },
              ]
            : undefined
        }
        columns={[
          {
            key: 'id',
            label: 'Order',
            cell: (row) => row.id,
            priority: 'primary',
            kind: 'identifier',
            sort: { href: '#data-table', direction: 'descending' },
          },
          { key: 'customer', label: 'Customer', cell: (row) => row.customer },
          { key: 'total', label: 'Total', cell: (row) => row.total, align: 'end', kind: 'currency' },
          {
            key: 'state',
            label: 'State',
            cell: (row) => <Badge label={row.state} tone={toneOf(row.state)} />,
            kind: 'status',
          },
        ]}
      />
    )
    
    const ListDemoChrome = (props: { id: string; selected?: number }): TemplateResult => (
      <ListChrome
        search={{
          id: `${props.id}-query`,
          action: `#${props.id}`,
          value: props.id === 'list-page' ? 'Mùa Hạ' : '',
          placeholder: 'Search records',
          hidden: { view: 'table' },
        }}
        facets={[
          { id: 'all', label: 'All', href: `#${props.id}`, active: true, count: 148 },
          { id: 'ready', label: 'Ready', href: `#${props.id}`, count: 91 },
          { id: 'review', label: 'Review', href: `#${props.id}`, count: 7 },
        ]}
        views={[
          { id: 'table', label: 'Table', href: `#${props.id}`, active: true },
          { id: 'kanban', label: 'Kanban', href: `#${props.id}` },
        ]}
        filtersToggle={{ label: 'Filters' }}
        sort={{
          id: `${props.id}-sort`,
          action: `#${props.id}`,
          choices: [
            { value: 'date-desc', label: 'Newest first', selected: true },
            { value: 'total-desc', label: 'Largest total' },
          ],
        }}
        bulk={{
          selectedCount: props.selected ?? 1,
          summary: `${props.selected ?? 1} selected`,
          clearHref: `#${props.id}`,
          actions: [{ id: 'approve', label: 'Approve', name: 'intent', value: 'approve', variant: 'primary' }],
        }}
        pager={{
          summary: 'Showing 1-3 of 148',
          previousHref: null,
          nextHref: `#${props.id}`,
          pages: [
            { label: '1', href: `#${props.id}`, active: true },
            { label: '2', href: `#${props.id}` },
          ],
        }}
      />
    )
    
    export const Example = () => (
      <DemoShell
        id="app-shell"
        active="collection"
        main={
          <ListPage
            variant="operational"
            context="Sales / Sales orders"
            title="Sales orders"
            headerActions={<Button label="Create order" variant="primary" />}
            actionsPlacement="header"
            actionsHidden
            actions={
              <BulkActions selectedCount={0} actions={[{ id: 'archive', label: 'Archive selected' }]} />
            }
            controls={<ListDemoChrome id="app-shell" />}
            body={<OrdersTable title="Order list" />}
          />
        }
      />
    )

    #Single-app shell

    A full-width top bar, primary sidebar and workspace for a single application.

    Projects

    Project activity

    OrderCustomerTotalState
    SO-1042Công ty Ánh Dương18.450.000 ₫Ready
    SO-1041Khách sạn Mùa Hạ6.800.000 ₫Review
    SO-1039Nguyễn Minh Châu2.150.000 ₫Blocked
    Show codeHide code
    import { TemplateResult } from '@ketvietlab/ketjs-view'
    import { AppBrand, AppNavigation, AppShell, AppTopbar, Badge, DataTable, Icon, NavigationToggle, Page } from 'faifo-design'
    
    type OrderRow = {
      id: string
      customer: string
      total: string
      state: 'Ready' | 'Review' | 'Blocked'
    }
    
    const orders: OrderRow[] = [
      { id: 'SO-1042', customer: 'Công ty Ánh Dương', total: '18.450.000 ₫', state: 'Ready' },
      { id: 'SO-1041', customer: 'Khách sạn Mùa Hạ', total: '6.800.000 ₫', state: 'Review' },
      { id: 'SO-1039', customer: 'Nguyễn Minh Châu', total: '2.150.000 ₫', state: 'Blocked' },
    ]
    
    const toneOf = (state: OrderRow['state']) =>
      state === 'Ready' ? ('positive' as const) : state === 'Review' ? ('warning' as const) : ('danger' as const)
    
    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 OrdersTable = (props: { grouped?: boolean; title?: string } = {}): TemplateResult => (
      <DataTable
        title={props.title}
        rows={props.grouped ? ([] as OrderRow[]) : orders}
        id={(row) => row.id}
        rowHref={(row) => `#${row.id}`}
        responsive="stack"
        selection={{ selectedIds: ['SO-1042'] }}
        groups={
          props.grouped
            ? [
                {
                  id: 'ready',
                  label: 'Ready to invoice',
                  count: 2,
                  rows: orders.slice(0, 2),
                  pager: { label: '2 shown in Ready', nextHref: '#data-table' },
                },
                {
                  id: 'blocked',
                  label: 'Needs decision',
                  count: 1,
                  rows: orders.slice(2),
                },
              ]
            : undefined
        }
        columns={[
          {
            key: 'id',
            label: 'Order',
            cell: (row) => row.id,
            priority: 'primary',
            kind: 'identifier',
            sort: { href: '#data-table', direction: 'descending' },
          },
          { key: 'customer', label: 'Customer', cell: (row) => row.customer },
          { key: 'total', label: 'Total', cell: (row) => row.total, align: 'end', kind: 'currency' },
          {
            key: 'state',
            label: 'State',
            cell: (row) => <Badge label={row.state} tone={toneOf(row.state)} />,
            kind: 'status',
          },
        ]}
      />
    )
    
    export const Example = () => (
      <AppShell
        mode="embedded"
        location={
          <AppTopbar
            brand={{ label: 'Projects', href: '#standalone-app-shell' }}
            location="Acme workspace"
            navigation={
              <NavigationToggle
                controls="demo-navigation-standalone-app-shell-drawer"
                label="Open navigation"
              />
            }
            search={{
              id: 'standalone-app-shell-search',
              action: '#standalone-app-shell',
              label: 'Search projects',
              placeholder: 'Search…',
              submitLabel: 'Search',
            }}
          />
        }
        sidebar={<DemoSidebar id="standalone-app-shell" active="collection" externalTrigger />}
        main={<Page title="Projects" body={<OrdersTable title="Project activity" />} />}
      />
    )

    #API

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

    #AppBrandComponent

    PropertyDescriptionTypeDefault
    labelrequired–string–
    hrefrequired–string–
    image–string–
    darkImage–string–
    imageFit–'contain' | 'cover'–
    variantShow the symbol at the start of a three-to-one brand lockup.'mark'–

    #AppSwitcherComponent

    Persistent app navigation; destinations and translated names belong to the host.

    PropertyDescriptionTypeDefault
    labelrequired–string–
    newTabLabel

    Deprecated App links open in the current tab and use the app name as their label.

    –
    string–
    brand–{ label: string; href: string; image: string; darkImage?: string }–
    navigation–{ controls: string; label: string; tools?: NavigationToolsProps }–
    helpLabel–string–
    helpSlotA fragment slot around Help, for a host whose navigation swaps the content and keeps the rail: each screen names its own guide, so the host sends Help again with the content it navigates to.string–
    settingsSettings beside Help: a menu of items, or, with href, a link to the settings page that gathers every module's configuration. current marks that page as open.| { id: string; label: string; items: readonly MenuEntry[]; href?: never; current?: never } | { id: string; label: string; href: string; current?: boolean; items?: never }–
    activeIdrequired–string–
    itemsrequired–readonly AppSwitcherItem[]–

    #AppSwitcherHelpComponent

    The same screen-owned HelpDrawer trigger for Suite rails and standalone app navigation.

    PropertyDescriptionTypeDefault
    labelrequired–string–

    #AppShellComponent

    PropertyDescriptionTypeDefault
    applications–AppSwitcherProps–
    topbar–JSXChild–
    location–JSXChild–
    sidebarrequired–JSXChild–
    mainrequired–JSXChild–
    rightRail–JSXChild–
    mode–'viewport' | 'embedded''viewport'

    #AppTopbarComponent

    Application identity and a compact launcher for a native GET search dialog.

    PropertyDescriptionTypeDefault
    brand–{ label: string; href: string; image?: string }–
    locationA location strip stays inside the main column, beside the sidebar identity.JSXChild–
    navigation–JSXChild–
    context–JSXChild–
    tools–JSXChild–
    searchrequired–{ /** A direct search workspace needs no native dialog/template or noscript copy. */ mode?: 'dialog' | 'link' id?: string action: string label: string triggerLabel?: string closeLabel?: string placeholder: string submitLabel: string query?: string locale?: string }–

    #Types

    #AppSwitcherItem

    PropertyDescriptionTypeDefault
    idrequired–string–
    labelrequired–string–
    href–string–
    sameTabLoad a new document (data-ket-reload) when the destination needs to replace the shell. All app links open in the current tab by default.boolean–
    unavailableLabelAn app without a destination is informative and cannot be opened.string–
    iconrequired–IconName–

    #AppSwitcherProps

    The properties of AppSwitcher, listed above.