Skip to content

ComponentsUtilities

SourceSource

App Launcher

The Apps launcher, as a desktop popout or a bottom sheet, with search, a recents strip and the apps installed in a server.

The Apps launcher, with search, a recents strip and the apps installed in a server. It is a popout on desktop and a bottom sheet on a phone. Compose it from the exported registry parts so local content and behaviour stay in the application while the visual contract stays token-driven.

Root class newt-app-launcher
import {
  AppLauncher,
  AppLauncherBody,
  AppLauncherHandle,
  AppLauncherItem,
  AppLauncherItemIcon,
  AppLauncherList,
  AppLauncherRecent,
  AppLauncherRecents,
  AppLauncherSearch,
  AppLauncherSearchInput,
  AppLauncherSection,
  AppLauncherSectionHeader,
  AppLauncherSectionTitle,
  AppLauncherViewMore,
} from "@/registry/bases/newt/ui/app-launcher"

const ShieldIcon = () => (
  <svg viewBox="0 0 24 24" fill="currentColor">
    <path d="M12 2 4 5v7c0 5 3.4 8.4 8 10 4.6-1.6 8-5 8-10V5l-8-3Z" />
  </svg>
)

const BoardIcon = () => (
  <svg viewBox="0 0 24 24" fill="currentColor">
    <path d="M4 4h16v12H8l-4 4V4Z" />
  </svg>
)

export default function AppLauncherDemo() {
  return (
    <AppLauncher inline label="Apps" className="h-[420px]">
      <AppLauncherHandle />

      <AppLauncherSearch>
        <AppLauncherSearchInput
          placeholder="Search Apps & Commands"
          aria-label="Search apps and commands"
        />
      </AppLauncherSearch>

      <AppLauncherBody>
        <AppLauncherSection aria-label="Recents">
          <AppLauncherSectionHeader>
            <AppLauncherSectionTitle>Recents</AppLauncherSectionTitle>
            <AppLauncherViewMore>View More</AppLauncherViewMore>
          </AppLauncherSectionHeader>
          <AppLauncherRecents aria-label="Recent apps">
            <AppLauncherRecent aria-label="Moderation">
              <ShieldIcon />
            </AppLauncherRecent>
            <AppLauncherRecent aria-label="Poll Night">
              <BoardIcon />
            </AppLauncherRecent>
          </AppLauncherRecents>
        </AppLauncherSection>

        <AppLauncherSection aria-label="Apps in this server">
          <AppLauncherSectionHeader>
            <AppLauncherSectionTitle>
              Apps in this Server
            </AppLauncherSectionTitle>
            <AppLauncherViewMore>View More</AppLauncherViewMore>
          </AppLauncherSectionHeader>
          <AppLauncherList>
            <AppLauncherItem
              name="Moderation"
              description="Bans, timeouts and audit logs."
              icon={
                <AppLauncherItemIcon round>
                  <ShieldIcon />
                </AppLauncherItemIcon>
              }
            />
            <AppLauncherItem
              promoted
              name="Poll Night"
              description="Run a quick poll in any channel."
              icon={
                <AppLauncherItemIcon>
                  <BoardIcon />
                </AppLauncherItemIcon>
              }
            />
          </AppLauncherList>
        </AppLauncherSection>
      </AppLauncherBody>
    </AppLauncher>
  )
}
<script setup lang="ts">
import {
  AppLauncher,
  AppLauncherBody,
  AppLauncherHandle,
  AppLauncherItem,
  AppLauncherItemIcon,
  AppLauncherList,
  AppLauncherRecent,
  AppLauncherRecents,
  AppLauncherSearch,
  AppLauncherSearchInput,
  AppLauncherSection,
  AppLauncherSectionHeader,
  AppLauncherSectionTitle,
  AppLauncherViewMore,
} from "~~/registry/bases/newt/ui/app-launcher"

const shieldPath = "M12 2 4 5v7c0 5 3.4 8.4 8 10 4.6-1.6 8-5 8-10V5l-8-3Z"
const boardPath = "M4 4h16v12H8l-4 4V4Z"
</script>

<template>
  <AppLauncher inline label="Apps" class="h-[420px]">
    <AppLauncherHandle />

    <AppLauncherSearch>
      <AppLauncherSearchInput
        placeholder="Search Apps & Commands"
        aria-label="Search apps and commands"
      />
    </AppLauncherSearch>

    <AppLauncherBody>
      <AppLauncherSection aria-label="Recents">
        <AppLauncherSectionHeader>
          <AppLauncherSectionTitle>Recents</AppLauncherSectionTitle>
          <AppLauncherViewMore>View More</AppLauncherViewMore>
        </AppLauncherSectionHeader>
        <AppLauncherRecents aria-label="Recent apps">
          <AppLauncherRecent aria-label="Moderation">
            <svg viewBox="0 0 24 24" fill="currentColor">
              <path :d="shieldPath" />
            </svg>
          </AppLauncherRecent>
          <AppLauncherRecent aria-label="Poll Night">
            <svg viewBox="0 0 24 24" fill="currentColor">
              <path :d="boardPath" />
            </svg>
          </AppLauncherRecent>
        </AppLauncherRecents>
      </AppLauncherSection>

      <AppLauncherSection aria-label="Apps in this server">
        <AppLauncherSectionHeader>
          <AppLauncherSectionTitle>Apps in this Server</AppLauncherSectionTitle>
          <AppLauncherViewMore>View More</AppLauncherViewMore>
        </AppLauncherSectionHeader>
        <AppLauncherList>
          <AppLauncherItem
            name="Moderation"
            description="Bans, timeouts and audit logs."
          >
            <template #icon>
              <AppLauncherItemIcon round>
                <svg viewBox="0 0 24 24" fill="currentColor">
                  <path :d="shieldPath" />
                </svg>
              </AppLauncherItemIcon>
            </template>
          </AppLauncherItem>
          <AppLauncherItem
            promoted
            name="Poll Night"
            description="Run a quick poll in any channel."
          >
            <template #icon>
              <AppLauncherItemIcon>
                <svg viewBox="0 0 24 24" fill="currentColor">
                  <path :d="boardPath" />
                </svg>
              </AppLauncherItemIcon>
            </template>
          </AppLauncherItem>
        </AppLauncherList>
      </AppLauncherSection>
    </AppLauncherBody>
  </AppLauncher>
</template>

Installation

npx newtui@latest add app-launchernpx shadcn@latest add @newtui/app-launchernpx shadcn-vue@latest add @newtui/app-launcherpnpm dlx newtui@latest add app-launcherpnpm dlx shadcn@latest add @newtui/app-launcherpnpm dlx shadcn-vue@latest add @newtui/app-launcheryarn dlx newtui@latest add app-launcheryarn dlx shadcn@latest add @newtui/app-launcheryarn dlx shadcn-vue@latest add @newtui/app-launcherbunx newtui@latest add app-launcherbunx shadcn@latest add @newtui/app-launcherbunx shadcn-vue@latest add @newtui/app-launcherdeno run -A npm:newtui@latest add app-launcherdeno run -A npm:shadcn@latest add @newtui/app-launcherdeno run -A npm:shadcn-vue@latest add @newtui/app-launchervlx newtui@latest add app-launchervlx shadcn@latest add @newtui/app-launchervlx shadcn-vue@latest add @newtui/app-launchervp dlx newtui@latest add app-launchervp dlx shadcn@latest add @newtui/app-launchervp dlx shadcn-vue@latest add @newtui/app-launchernubx newtui@latest add app-launchernubx shadcn@latest add @newtui/app-launchernubx shadcn-vue@latest add @newtui/app-launchernlx newtui@latest add app-launchernlx shadcn@latest add @newtui/app-launchernlx shadcn-vue@latest add @newtui/app-launcherupx newtui@latest add app-launcherupx shadcn@latest add @newtui/app-launcherupx shadcn-vue@latest add @newtui/app-launcher

The shadcn CLI needs the @newtui registry in your components.json. Set it up.

Install the dependencies

npm install class-variance-authority radix-uipnpm add class-variance-authority radix-uiyarn add class-variance-authority radix-uibun add class-variance-authority radix-uideno add npm:class-variance-authority npm:radix-uivlt install class-variance-authority radix-uivp add class-variance-authority radix-uinub add class-variance-authority radix-uini class-variance-authority radix-uiupm add class-variance-authority radix-ui
npm install class-variance-authority reka-uipnpm add class-variance-authority reka-uiyarn add class-variance-authority reka-uibun add class-variance-authority reka-uideno add npm:class-variance-authority npm:reka-uivlt install class-variance-authority reka-uivp add class-variance-authority reka-uinub add class-variance-authority reka-uini class-variance-authority reka-uiupm add class-variance-authority reka-ui

Add the components it builds on

Copy the source into your project

"use client"

import { cva, type VariantProps } from "class-variance-authority"
import { Dialog as DialogPrimitive } from "radix-ui"
import * as React from "react"

import { cn } from "@/lib/utils"
import { scrollbarClassName } from "@/registry/bases/newt/ui/scrollbar"

const appLauncherVariants = cva(
  "flex w-full flex-col overflow-hidden border border-newt-border bg-newt-bg-surface text-newt-text-primary shadow-elevation-high",
  {
    variants: {
      variant: {
        /* The desktop popout, at a fixed size. */
        popout:
          "h-[min(680px,calc(100dvh-2rem))] max-w-[504px] rounded-[var(--newt-radius-md)]",
        /* The bottom sheet: full width, rising from the bottom edge. */
        sheet:
          "h-[var(--newt-app-launcher-sheet-height,90dvh)] max-w-none rounded-t-[var(--newt-radius-lg)] border-b-0",
      },
    },
    defaultVariants: { variant: "popout" },
  }
)

export interface AppLauncherProps
  extends
    React.ComponentProps<"div">,
    VariantProps<typeof appLauncherVariants> {
  /**
   * Render the launcher in the page: no dialog role, and focus stays where it
   * is. Use it for a launcher that is always on screen, such as a showcase.
   */
  inline?: boolean
  /**
   * Take the page behind the launcher out of use: it is hidden from assistive
   * technology, focus cannot move to it, and a press on it closes the
   * launcher. Use it for a sheet that covers the page. Has no effect on an
   * `inline` launcher.
   */
  modal?: boolean
  /**
   * The accessible name of the launcher. Without it, name the launcher with
   * `aria-label` or `aria-labelledby`.
   */
  label?: string
  /**
   * Called when the user asks to close the dialog: Escape, or a press outside
   * a `modal` one. Unmount the launcher in answer; focus then returns to the
   * element that held it before the launcher opened.
   */
  onClose?: () => void
}

/*
 * Radix owns the behaviour: focus moves into the launcher, Tab cycles through
 * its controls, Escape asks to close it, and a `modal` one takes the page
 * behind it out of use. The launcher renders in place, with no portal and no
 * overlay, so the application decides where it sits. It is open for as long
 * as it is mounted.
 */
const AppLauncherDialog = React.forwardRef<
  HTMLDivElement,
  Omit<AppLauncherProps, "inline" | "variant"> & { variantClassName: string }
>(
  (
    {
      modal = false,
      label,
      onClose,
      variantClassName,
      className,
      children,
      ...props
    },
    ref
  ) => {
    const opener = React.useRef<Element | null>(null)
    return (
      <DialogPrimitive.Root
        open
        modal={modal}
        onOpenChange={(open) => {
          if (!open) onClose?.()
        }}
      >
        <DialogPrimitive.Content
          ref={ref}
          aria-modal={modal ? true : undefined}
          aria-describedby={undefined}
          /*
           * Radix returns focus to a `Dialog.Trigger`, and this dialog has
           * none: the application opens it by mounting it. So the launcher
           * notes which element holds focus just before it takes it.
           */
          onOpenAutoFocus={() => {
            opener.current = document.activeElement
          }}
          onCloseAutoFocus={(event) => {
            event.preventDefault()
            const element = opener.current
            if (element instanceof HTMLElement && element.isConnected)
              element.focus()
          }}
          /*
           * The page beside a dialog that is not modal stays in use, so a
           * press or a focus move outside must not close the launcher.
           */
          onInteractOutside={(event) => {
            if (!modal) event.preventDefault()
          }}
          className={cn(variantClassName, "outline-none", className)}
          /*
           * Without a `label` there is no title. Older Radix releases still
           * point the dialog at the title's id, which names nothing, so an
           * `aria-label` would go unread. `aria-labelledby` from props wins.
           */
          {...(label === undefined ? { "aria-labelledby": undefined } : {})}
          {...props}
        >
          {/* The name, as a heading no one sees: Radix points the dialog at it. */}
          {label === undefined ? null : (
            <DialogPrimitive.Title className="sr-only">
              {label}
            </DialogPrimitive.Title>
          )}
          {children}
        </DialogPrimitive.Content>
      </DialogPrimitive.Root>
    )
  }
)
AppLauncherDialog.displayName = "AppLauncherDialog"

/*
 * The Apps launcher: search, recents, and the apps installed in a server. It
 * is a popout on desktop and a bottom sheet on a phone, and a dialog unless
 * it is `inline`.
 */
const AppLauncher = React.forwardRef<HTMLDivElement, AppLauncherProps>(
  ({ inline = false, variant, ...props }, ref) => {
    const variantClassName = appLauncherVariants({ variant })
    if (!inline)
      return (
        <AppLauncherDialog
          ref={ref}
          variantClassName={variantClassName}
          {...props}
        />
      )
    const { modal: _modal, onClose: _onClose, label, role, ...rest } = props
    return (
      <div
        ref={ref}
        /* A name needs a role to hang on: a `div` alone may not carry one. */
        role={role ?? (label === undefined ? undefined : "region")}
        aria-label={label}
        {...rest}
        className={cn(variantClassName, rest.className)}
      />
    )
  }
)
AppLauncher.displayName = "AppLauncher"

export interface AppLauncherHandleProps extends React.HTMLAttributes<HTMLElement> {
  /**
   * The accessible name of the handle. Pass it to render the handle as a
   * button that expands or collapses the sheet. Without it, the handle is a
   * decorative grip that assistive technology skips.
   */
  label?: string
  /** Whether the sheet is expanded, reported as `aria-expanded`. */
  expanded?: boolean
}

const gripClassName = "h-1 w-9 shrink-0 rounded-full bg-newt-border"

/* The element is picked at runtime, so the ref keeps its public type. */
function handleElement(interactive: boolean): React.ElementType {
  return interactive ? "button" : "div"
}

/*
 * Grip shown when the launcher is presented as a bottom sheet. With a
 * `label` it is a button: native, so Enter and Space press it.
 */
const AppLauncherHandle = React.forwardRef<HTMLElement, AppLauncherHandleProps>(
  ({ className, label, expanded, ...props }, ref) => {
    const interactive = label !== undefined
    const Tag = handleElement(interactive)
    return (
      <Tag
        ref={ref}
        type={interactive ? "button" : undefined}
        aria-label={label}
        aria-expanded={interactive ? expanded : undefined}
        aria-hidden={interactive ? undefined : true}
        className={cn(
          interactive
            ? "group mx-auto mt-1.5 flex h-6 w-12 shrink-0 cursor-pointer items-center justify-center rounded-full border-0 bg-transparent p-0 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link"
            : cn("mx-auto mt-2", gripClassName),
          className
        )}
        {...props}
      >
        {interactive ? (
          <span
            aria-hidden="true"
            className={cn(gripClassName, "group-hover:bg-newt-text-muted")}
          />
        ) : null}
      </Tag>
    )
  }
)
AppLauncherHandle.displayName = "AppLauncherHandle"

/* Drill-in header: back control on the left, view title beside it. */
const AppLauncherHeader = React.forwardRef<
  HTMLDivElement,
  React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "flex h-14 shrink-0 items-center gap-2 px-2 text-base font-semibold",
      className
    )}
    {...props}
  />
))
AppLauncherHeader.displayName = "AppLauncherHeader"

/*
 * Title of a drill-in view. It takes the free width and centres in it, so put
 * a spacer as wide as the back control after it to centre it in the header.
 */
const AppLauncherHeaderTitle = React.forwardRef<
  HTMLHeadingElement,
  React.ComponentProps<"h2">
>(({ className, ...props }, ref) => (
  <h2
    ref={ref}
    className={cn(
      "m-0 min-w-0 flex-1 truncate text-center text-base font-semibold text-newt-text-primary",
      className
    )}
    {...props}
  />
))
AppLauncherHeaderTitle.displayName = "AppLauncherHeaderTitle"

const AppLauncherBack = React.forwardRef<
  HTMLButtonElement,
  React.ComponentProps<"button">
>(({ className, type = "button", ...props }, ref) => (
  <button
    ref={ref}
    type={type}
    className={cn(
      "inline-flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full border-0 bg-newt-bg-elevated p-0 text-newt-text-secondary transition-colors duration-fast ease-newt",
      "hover:bg-newt-bg-hover hover:text-newt-text-primary",
      "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link",
      className
    )}
    {...props}
  />
))
AppLauncherBack.displayName = "AppLauncherBack"

const SearchIcon = () => (
  <svg
    viewBox="0 0 20 20"
    fill="none"
    stroke="currentColor"
    strokeWidth="2"
    strokeLinecap="round"
    aria-hidden="true"
    className="pointer-events-none absolute start-3.5 top-1/2 h-5 w-5 -translate-y-1/2 text-newt-text-muted"
  >
    <circle cx="9" cy="9" r="5.5" />
    <path d="M13 13l4 4" />
  </svg>
)

/* Search field wrapper; place an `<AppLauncherSearchInput>` inside it. */
const AppLauncherSearch = React.forwardRef<
  HTMLDivElement,
  React.ComponentProps<"div">
>(({ className, children, ...props }, ref) => (
  <div
    ref={ref}
    className={cn("shrink-0 px-4 pb-3 pt-4", className)}
    {...props}
  >
    <div className="relative flex items-center">
      <SearchIcon />
      {children}
    </div>
  </div>
))
AppLauncherSearch.displayName = "AppLauncherSearch"

export interface AppLauncherSearchInputProps extends React.ComponentProps<"input"> {
  /** Called with the text of the field on each change, after `onChange`. */
  onValueChange?: (value: string) => void
}

/* Pass `value` and `onValueChange` to control the query. */
const AppLauncherSearchInput = React.forwardRef<
  HTMLInputElement,
  AppLauncherSearchInputProps
>(({ className, type = "search", onChange, onValueChange, ...props }, ref) => (
  <input
    ref={ref}
    type={type}
    autoComplete="off"
    spellCheck={false}
    className={cn(
      "h-11 w-full appearance-none rounded-[var(--newt-radius-md)] border-2 border-transparent bg-newt-bg-input py-0 ps-11 pe-3 text-base text-newt-text-primary outline-none",
      "placeholder:text-newt-text-muted focus:border-newt-brand",
      className
    )}
    onChange={(event) => {
      onChange?.(event)
      onValueChange?.(event.target.value)
    }}
    {...props}
  />
))
AppLauncherSearchInput.displayName = "AppLauncherSearchInput"

const AppLauncherBody = React.forwardRef<
  HTMLDivElement,
  React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto px-4 pb-4",
      scrollbarClassName,
      className
    )}
    {...props}
  />
))
AppLauncherBody.displayName = "AppLauncherBody"

const AppLauncherSection = React.forwardRef<
  HTMLElement,
  React.ComponentProps<"section">
>(({ className, ...props }, ref) => (
  <section
    ref={ref}
    className={cn("flex flex-col gap-2", className)}
    {...props}
  />
))
AppLauncherSection.displayName = "AppLauncherSection"

const AppLauncherSectionHeader = React.forwardRef<
  HTMLDivElement,
  React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn("flex items-center justify-between gap-2 px-0.5", className)}
    {...props}
  />
))
AppLauncherSectionHeader.displayName = "AppLauncherSectionHeader"

const AppLauncherSectionTitle = React.forwardRef<
  HTMLHeadingElement,
  React.ComponentProps<"h2">
>(({ className, ...props }, ref) => (
  <h2
    ref={ref}
    className={cn(
      "m-0 inline-flex items-center gap-1 text-base font-medium text-newt-text-primary",
      className
    )}
    {...props}
  />
))
AppLauncherSectionTitle.displayName = "AppLauncherSectionTitle"

const AppLauncherViewMore = React.forwardRef<
  HTMLButtonElement,
  React.ComponentProps<"button">
>(({ className, type = "button", ...props }, ref) => (
  <button
    ref={ref}
    type={type}
    className={cn(
      "cursor-pointer rounded-[var(--newt-radius-sm)] border-0 bg-transparent p-0 text-base font-semibold text-newt-text-link no-underline hover:underline",
      "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link",
      className
    )}
    {...props}
  />
))
AppLauncherViewMore.displayName = "AppLauncherViewMore"

export interface AppLauncherListProps extends React.ComponentProps<"div"> {
  /**
   * `stack` puts rows behind one rounded surface. `grid` lays out
   * `variant="tile"` items in columns.
   */
  variant?: "stack" | "grid"
}

/* Card that stacks `<AppLauncherItem>` rows behind one rounded surface. */
const AppLauncherList = React.forwardRef<HTMLDivElement, AppLauncherListProps>(
  ({ className, variant = "stack", ...props }, ref) => (
    <div
      ref={ref}
      className={cn(
        variant === "grid"
          ? "grid grid-cols-[repeat(auto-fill,minmax(88px,1fr))] gap-2"
          : "flex flex-col overflow-hidden rounded-[var(--newt-radius-md)] bg-newt-bg-elevated [&>*+*]:border-t [&>*+*]:border-newt-border",
        className
      )}
      {...props}
    />
  )
)
AppLauncherList.displayName = "AppLauncherList"

export interface AppLauncherItemProps extends Omit<
  React.ComponentProps<"button">,
  "children"
> {
  name: string
  description?: string
  /** Icon for the app; pair with `<AppLauncherItemIcon>`. */
  icon?: React.ReactNode
  /** Marks a paid placement, as the client does for promoted apps. */
  promoted?: boolean
  /** Text of the `promoted` badge, also part of the button's name. */
  promotedLabel?: string
  /**
   * Content after the text, such as a chevron or a visibility toggle. It sits
   * beside the item's button, so it can hold a control of its own.
   */
  trailing?: React.ReactNode
  /**
   * `row` puts the icon beside the text. `tile` puts it above, for a
   * `variant="grid"` list.
   */
  variant?: "row" | "tile"
}

/*
 * The row is a wrapper that holds the item's button and, beside it, the
 * `trailing` content. A control in `trailing` is then not nested in the
 * button. The button's `::after` covers the whole row, so a press anywhere
 * else on the row, a chevron included, presses the button. `className`
 * styles the row; the ref and the other props go to the button.
 */
const AppLauncherItem = React.forwardRef<
  HTMLButtonElement,
  AppLauncherItemProps
>(
  (
    {
      className,
      name,
      description,
      icon,
      promoted = false,
      promotedLabel = "Promoted",
      trailing,
      variant = "row",
      type = "button",
      ...props
    },
    ref
  ) => (
    <div
      className={cn(
        "relative flex w-full items-center transition-colors duration-fast ease-newt",
        variant === "tile"
          ? "flex-col gap-2 rounded-[var(--newt-radius-md)] bg-newt-bg-elevated px-2 py-3"
          : "gap-3 px-3 py-3",
        "hover:bg-newt-bg-hover",
        className
      )}
    >
      <button
        ref={ref}
        type={type}
        className={cn(
          "flex min-w-0 cursor-pointer items-center border-0 bg-transparent p-0 outline-none",
          variant === "tile"
            ? "w-full flex-col gap-2 text-center after:rounded-[var(--newt-radius-md)]"
            : "flex-1 gap-3 text-start",
          "after:absolute after:inset-0",
          "focus-visible:after:outline focus-visible:after:outline-2 focus-visible:after:-outline-offset-2 focus-visible:after:outline-newt-text-link"
        )}
        {...props}
      >
        {icon}
        <span
          className={cn(
            "flex min-w-0 flex-col gap-0.5",
            variant === "tile" ? "w-full" : "flex-1"
          )}
        >
          <span
            className={cn(
              "flex min-w-0 items-center gap-1.5",
              variant === "tile" && "justify-center"
            )}
          >
            <span className="truncate text-base font-medium leading-tight text-newt-text-primary">
              {name}
            </span>
            {promoted ? (
              <span className="shrink-0 rounded-full bg-newt-text-primary px-1.5 py-0.5 text-[10px] font-bold uppercase leading-none tracking-wide text-newt-bg-surface">
                {promotedLabel}
              </span>
            ) : null}
          </span>
          {description ? (
            <span className="truncate text-sm leading-snug text-newt-text-muted">
              {description}
            </span>
          ) : null}
        </span>
      </button>
      {trailing ? (
        /* A press passes through to the button, unless it lands on a control. */
        <span className="pointer-events-none inline-flex shrink-0 items-center gap-1 text-newt-text-muted [&>svg]:h-5 [&>svg]:w-5 [&_:is(a,button,input,label,select,textarea)]:pointer-events-auto [&_:is(a,button,input,label,select,textarea)]:relative">
          {trailing}
        </span>
      ) : null}
    </div>
  )
)
AppLauncherItem.displayName = "AppLauncherItem"

export interface AppLauncherItemIconProps extends React.ComponentProps<"span"> {
  /** Bots use circular avatars; games and activities keep the squircle. */
  round?: boolean
  /**
   * How an `<img>` inside fills the icon: `cover` crops it, `contain`
   * shows all of it, for a logo that must not be cut.
   */
  fit?: "cover" | "contain"
}

const AppLauncherItemIcon = React.forwardRef<
  HTMLSpanElement,
  AppLauncherItemIconProps
>(({ className, round = false, fit = "cover", ...props }, ref) => (
  <span
    ref={ref}
    aria-hidden="true"
    className={cn(
      "inline-flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden bg-newt-bg-base text-newt-text-secondary",
      round ? "rounded-full" : "rounded-[10px]",
      "[&>img]:h-full [&>img]:w-full [&>svg]:h-5 [&>svg]:w-5",
      fit === "contain" ? "[&>img]:object-contain" : "[&>img]:object-cover",
      className
    )}
    {...props}
  />
))
AppLauncherItemIcon.displayName = "AppLauncherItemIcon"

/*
 * Horizontal strip of recently used apps, as a list: a screen reader
 * announces how many there are. Name it with `aria-label` or
 * `aria-labelledby`.
 */
const AppLauncherRecents = React.forwardRef<
  HTMLUListElement,
  React.ComponentProps<"ul">
>(({ className, role = "list", ...props }, ref) => (
  <ul
    ref={ref}
    /* `list-style: none` drops the list role in Safari; this keeps it. */
    role={role}
    className={cn(
      "m-0 flex list-none gap-3 overflow-x-auto p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
      className
    )}
    {...props}
  />
))
AppLauncherRecents.displayName = "AppLauncherRecents"

export interface AppLauncherRecentProps extends React.ComponentProps<"button"> {
  /**
   * How an `<img>` inside fills the tile: `cover` crops it, `contain`
   * shows all of it, for a logo that must not be cut.
   */
  fit?: "cover" | "contain"
}

/* One recent app: a list item holding the button the props apply to. */
const AppLauncherRecent = React.forwardRef<
  HTMLButtonElement,
  AppLauncherRecentProps
>(({ className, fit = "cover", type = "button", ...props }, ref) => (
  <li className="flex shrink-0">
    <button
      ref={ref}
      type={type}
      className={cn(
        "inline-flex h-12 w-12 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-[14px] border-0 bg-newt-bg-base p-0 text-newt-text-secondary transition-[filter] duration-fast ease-newt",
        "hover:brightness-110",
        "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link",
        "[&>img]:h-full [&>img]:w-full [&>svg]:h-6 [&>svg]:w-6",
        fit === "contain" ? "[&>img]:object-contain" : "[&>img]:object-cover",
        className
      )}
      {...props}
    />
  </li>
))
AppLauncherRecent.displayName = "AppLauncherRecent"

export interface AppLauncherPromoCardProps extends Omit<
  React.ComponentProps<"button">,
  "children"
> {
  /** The artwork across the top. An `<img>` fills it and is cropped. */
  art?: React.ReactNode
  /** The row below the art, such as an icon, the app name and a line. */
  footer?: React.ReactNode
}

/* A promoted app: art on top, a footer with its name below. */
const AppLauncherPromoCard = React.forwardRef<
  HTMLButtonElement,
  AppLauncherPromoCardProps
>(({ className, art, footer, type = "button", ...props }, ref) => (
  <button
    ref={ref}
    type={type}
    className={cn(
      "flex w-full shrink-0 cursor-pointer flex-col overflow-hidden rounded-[var(--newt-radius-md)] border-0 bg-newt-bg-elevated p-0 text-start text-newt-text-primary transition-colors duration-fast ease-newt",
      "hover:bg-newt-bg-hover",
      "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link",
      className
    )}
    {...props}
  >
    {art ? (
      <span className="block aspect-video overflow-hidden bg-newt-bg-base [&>img]:block [&>img]:h-full [&>img]:w-full [&>img]:object-cover">
        {art}
      </span>
    ) : null}
    {footer ? (
      <span className="flex min-w-0 items-center gap-3 p-3">{footer}</span>
    ) : null}
  </button>
))
AppLauncherPromoCard.displayName = "AppLauncherPromoCard"

export {
  AppLauncher,
  appLauncherVariants,
  AppLauncherHandle,
  AppLauncherHeader,
  AppLauncherHeaderTitle,
  AppLauncherBack,
  AppLauncherSearch,
  AppLauncherSearchInput,
  AppLauncherBody,
  AppLauncherSection,
  AppLauncherSectionHeader,
  AppLauncherSectionTitle,
  AppLauncherViewMore,
  AppLauncherList,
  AppLauncherItem,
  AppLauncherItemIcon,
  AppLauncherRecents,
  AppLauncherRecent,
  AppLauncherPromoCard,
}
<script setup lang="ts">
import { DialogContent, DialogRoot, DialogTitle } from "reka-ui"
import type { HTMLAttributes } from "vue"
import { computed, useAttrs } from "vue"

import { cn } from "@/lib/utils"

import { type AppLauncherVariants, appLauncherVariants } from "."

/*
 * The Apps launcher: search, recents, and the apps installed in a server. It
 * is a popout on desktop and a bottom sheet on a phone, and a dialog unless
 * it is `inline`.
 *
 * Reka owns the dialog behaviour: focus moves into the launcher, Tab cycles
 * through its controls, Escape asks to close it, and a `modal` one takes the
 * page behind it out of use. The launcher renders in place, with no portal
 * and no overlay, so the application decides where it sits. It is open for
 * as long as it is mounted. The page beside a dialog that is not modal stays
 * in use, so a press or a focus move outside does not close it.
 */
defineOptions({ inheritAttrs: false })

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /** `popout` for desktop, `sheet` for a bottom sheet on a phone. */
    variant?: AppLauncherVariants["variant"]
    /**
     * Render the launcher in the page: no dialog role, and focus stays where
     * it is. Use it for a launcher that is always on screen, such as a
     * showcase.
     */
    inline?: boolean
    /**
     * Take the page behind the launcher out of use: it is hidden from
     * assistive technology, focus cannot move to it, and a press on it
     * closes the launcher. Use it for a sheet that covers the page. Has no
     * effect on an `inline` launcher.
     */
    modal?: boolean
    /**
     * The accessible name of the launcher. Without it, name the launcher
     * with `aria-label` or `aria-labelledby`.
     */
    label?: string
  }>(),
  { variant: "popout", inline: false, modal: false }
)

const emit = defineEmits<{
  /**
   * The user asks to close the dialog: Escape, or a press outside a `modal`
   * one. Unmount the launcher in answer; focus then returns to the element
   * that held it before the launcher opened.
   */
  close: []
}>()

const attrs = useAttrs()

const launcherClass = computed(() =>
  appLauncherVariants({ variant: props.variant })
)

/*
 * Reka always points the dialog at a title. Without a `label` there is none,
 * so the reference gives way to whatever name the application passes.
 */
const naming = computed(() =>
  props.label === undefined
    ? { "aria-labelledby": attrs["aria-labelledby"] }
    : {}
)

/*
 * The dialog has no trigger: the application opens it by mounting it. So the
 * launcher notes which element holds focus just before it takes it, and
 * hands focus back to that element when it unmounts.
 */
let opener: Element | null = null

function rememberOpener() {
  opener = document.activeElement
}

function returnFocus(event: Event) {
  event.preventDefault()
  const element = opener
  /*
   * A press outside closes a modal launcher while the press is still in
   * flight, and the browser then moves focus to the page. The timer runs
   * after it.
   */
  setTimeout(() => {
    if (element instanceof HTMLElement && element.isConnected) element.focus()
  }, 0)
}
</script>

<template>
  <!-- A name needs a role to hang on: a `div` alone may not carry one. -->
  <div
    v-if="props.inline"
    :role="props.label === undefined ? undefined : 'region'"
    :aria-label="props.label"
    v-bind="$attrs"
    :class="cn(launcherClass, props.class)"
  >
    <slot />
  </div>
  <DialogRoot
    v-else
    :open="true"
    :modal="props.modal"
    @update:open="
      (open) => {
        if (!open) emit('close')
      }
    "
  >
    <DialogContent
      v-bind="{ ...$attrs, ...naming }"
      :aria-modal="props.modal ? true : undefined"
      :aria-describedby="undefined"
      :class="cn(launcherClass, 'outline-none', props.class)"
      @open-auto-focus="rememberOpener"
      @close-auto-focus="returnFocus"
      @interact-outside="
        (event) => {
          if (!props.modal) event.preventDefault()
        }
      "
    >
      <!-- The name, as a heading no one sees: Reka points the dialog at it. -->
      <DialogTitle v-if="props.label !== undefined" class="sr-only">
        {{ props.label }}
      </DialogTitle>
      <slot />
    </DialogContent>
  </DialogRoot>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /**
     * The accessible name of the handle. Pass it to render the handle as a
     * button that expands or collapses the sheet. Without it, the handle is
     * a decorative grip that assistive technology skips.
     */
    label?: string
    /** Whether the sheet is expanded, reported as `aria-expanded`. */
    expanded?: boolean
  }>(),
  /*
   * Vue casts an absent `boolean` prop to `false` unless it has a `default`
   * key. `undefined` keeps `aria-expanded` off a handle that does not say.
   */
  { expanded: undefined }
)

const gripClass = "h-1 w-9 shrink-0 rounded-full bg-newt-border"
</script>

<template>
  <!-- Grip shown when the launcher is presented as a bottom sheet. -->
  <div
    v-if="props.label === undefined"
    aria-hidden="true"
    :class="cn('mx-auto mt-2', gripClass, props.class)"
  />
  <button
    v-else
    type="button"
    :aria-label="props.label"
    :aria-expanded="props.expanded"
    :class="
      cn(
        'group mx-auto mt-1.5 flex h-6 w-12 shrink-0 cursor-pointer items-center justify-center rounded-full border-0 bg-transparent p-0',
        'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link',
        props.class
      )
    "
  >
    <span
      aria-hidden="true"
      :class="cn(gripClass, 'group-hover:bg-newt-text-muted')"
    />
  </button>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <div
    :class="
      cn(
        'flex h-14 shrink-0 items-center gap-2 px-2 text-base font-semibold',
        props.class
      )
    "
  >
    <slot />
  </div>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <!--
    Title of a drill-in view. It takes the free width and centres in it, so
    put a spacer as wide as the back control after it to centre it in the
    header.
  -->
  <h2
    :class="
      cn(
        'm-0 min-w-0 flex-1 truncate text-center text-base font-semibold text-newt-text-primary',
        props.class
      )
    "
  >
    <slot />
  </h2>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <button
    type="button"
    :class="
      cn(
        'inline-flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full border-0 bg-newt-bg-elevated p-0 text-newt-text-secondary transition-colors duration-fast ease-newt',
        'hover:bg-newt-bg-hover hover:text-newt-text-primary',
        'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link',
        props.class
      )
    "
  >
    <slot />
  </button>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <!-- Search field wrapper; place an `<AppLauncherSearchInput>` inside it. -->
  <div :class="cn('shrink-0 px-4 pb-3 pt-4', props.class)">
    <div class="relative flex items-center">
      <svg
        viewBox="0 0 20 20"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
        stroke-linecap="round"
        aria-hidden="true"
        class="pointer-events-none absolute start-3.5 top-1/2 h-5 w-5 -translate-y-1/2 text-newt-text-muted"
      >
        <circle cx="9" cy="9" r="5.5" />
        <path d="M13 13l4 4" />
      </svg>
      <slot />
    </div>
  </div>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
/* Bind the query with `v-model`. */
const model = defineModel<string>()
</script>

<template>
  <input
    v-model="model"
    type="search"
    autocomplete="off"
    spellcheck="false"
    :class="
      cn(
        'h-11 w-full appearance-none rounded-[var(--newt-radius-md)] border-2 border-transparent bg-newt-bg-input py-0 ps-11 pe-3 text-base text-newt-text-primary outline-none',
        'placeholder:text-newt-text-muted focus:border-newt-brand',
        props.class
      )
    "
  />
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { scrollbarClassName } from "~~/registry/bases/newt/ui/scrollbar"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <div
    :class="
      cn(
        'flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto px-4 pb-4',
        scrollbarClassName,
        props.class
      )
    "
  >
    <slot />
  </div>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <section :class="cn('flex flex-col gap-2', props.class)">
    <slot />
  </section>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <div
    :class="cn('flex items-center justify-between gap-2 px-0.5', props.class)"
  >
    <slot />
  </div>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <h2
    :class="
      cn(
        'm-0 inline-flex items-center gap-1 text-base font-medium text-newt-text-primary',
        props.class
      )
    "
  >
    <slot />
  </h2>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <button
    type="button"
    :class="
      cn(
        'cursor-pointer rounded-[var(--newt-radius-sm)] border-0 bg-transparent p-0 text-base font-semibold text-newt-text-link no-underline hover:underline',
        'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link',
        props.class
      )
    "
  >
    <slot />
  </button>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /**
     * `stack` puts rows behind one rounded surface. `grid` lays out
     * `variant="tile"` items in columns.
     */
    variant?: "stack" | "grid"
  }>(),
  { variant: "stack" }
)
</script>

<template>
  <!-- Card that stacks `<AppLauncherItem>` rows behind one rounded surface. -->
  <div
    :class="
      cn(
        props.variant === 'grid'
          ? 'grid grid-cols-[repeat(auto-fill,minmax(88px,1fr))] gap-2'
          : 'flex flex-col overflow-hidden rounded-[var(--newt-radius-md)] bg-newt-bg-elevated [&>*+*]:border-t [&>*+*]:border-newt-border',
        props.class
      )
    "
  >
    <slot />
  </div>
</template>
<script setup lang="ts">
import type { HTMLAttributes, VNode } from "vue"

import { cn } from "@/lib/utils"

/*
 * The row is a wrapper that holds the item's button and, beside it, the
 * `#trailing` content. A control in `#trailing` is then not nested in the
 * button. The button's `::after` covers the whole row, so a press anywhere
 * else on the row, a chevron included, presses the button. `class` styles
 * the row; the other attributes go to the button.
 */
defineOptions({ inheritAttrs: false })

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    name: string
    description?: string
    /** Marks a paid placement, as the client does for promoted apps. */
    promoted?: boolean
    /** Text of the `promoted` badge, also part of the button's name. */
    promotedLabel?: string
    /**
     * `row` puts the icon beside the text. `tile` puts it above, for a
     * `variant="grid"` list.
     */
    variant?: "row" | "tile"
  }>(),
  { promoted: false, promotedLabel: "Promoted", variant: "row" }
)

defineSlots<{
  /** Icon for the app; pair with `<AppLauncherItemIcon>`. */
  icon?: () => VNode[]
  /**
   * Content after the text, such as a chevron or a visibility toggle. It sits
   * beside the item's button, so it can hold a control of its own.
   */
  trailing?: () => VNode[]
}>()
</script>

<template>
  <div
    :class="
      cn(
        'relative flex w-full items-center transition-colors duration-fast ease-newt',
        props.variant === 'tile'
          ? 'flex-col gap-2 rounded-[var(--newt-radius-md)] bg-newt-bg-elevated px-2 py-3'
          : 'gap-3 px-3 py-3',
        'hover:bg-newt-bg-hover',
        props.class
      )
    "
  >
    <button
      type="button"
      v-bind="$attrs"
      :class="
        cn(
          'flex min-w-0 cursor-pointer items-center border-0 bg-transparent p-0 outline-none',
          props.variant === 'tile'
            ? 'w-full flex-col gap-2 text-center after:rounded-[var(--newt-radius-md)]'
            : 'flex-1 gap-3 text-start',
          'after:absolute after:inset-0',
          'focus-visible:after:outline focus-visible:after:outline-2 focus-visible:after:-outline-offset-2 focus-visible:after:outline-newt-text-link'
        )
      "
    >
      <slot name="icon" />
      <span
        :class="
          cn(
            'flex min-w-0 flex-col gap-0.5',
            props.variant === 'tile' ? 'w-full' : 'flex-1'
          )
        "
      >
        <span
          :class="
            cn(
              'flex min-w-0 items-center gap-1.5',
              props.variant === 'tile' && 'justify-center'
            )
          "
        >
          <span
            class="truncate text-base font-medium leading-tight text-newt-text-primary"
          >
            {{ props.name }}
          </span>
          <span
            v-if="props.promoted"
            class="shrink-0 rounded-full bg-newt-text-primary px-1.5 py-0.5 text-[10px] font-bold uppercase leading-none tracking-wide text-newt-bg-surface"
          >
            {{ props.promotedLabel }}
          </span>
        </span>
        <span
          v-if="props.description"
          class="truncate text-sm leading-snug text-newt-text-muted"
        >
          {{ props.description }}
        </span>
      </span>
    </button>
    <!-- A press passes through to the button, unless it lands on a control. -->
    <span
      v-if="$slots.trailing"
      class="pointer-events-none inline-flex shrink-0 items-center gap-1 text-newt-text-muted [&>svg]:h-5 [&>svg]:w-5 [&_:is(a,button,input,label,select,textarea)]:pointer-events-auto [&_:is(a,button,input,label,select,textarea)]:relative"
    >
      <slot name="trailing" />
    </span>
  </div>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /** Bots use circular avatars; games and activities keep the squircle. */
    round?: boolean
    /**
     * How an `<img>` inside fills the icon: `cover` crops it, `contain`
     * shows all of it, for a logo that must not be cut.
     */
    fit?: "cover" | "contain"
  }>(),
  { round: false, fit: "cover" }
)
</script>

<template>
  <span
    aria-hidden="true"
    :class="
      cn(
        'inline-flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden bg-newt-bg-base text-newt-text-secondary',
        props.round ? 'rounded-full' : 'rounded-[10px]',
        '[&>img]:h-full [&>img]:w-full [&>svg]:h-5 [&>svg]:w-5',
        props.fit === 'contain'
          ? '[&>img]:object-contain'
          : '[&>img]:object-cover',
        props.class
      )
    "
  >
    <slot />
  </span>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <!--
    Horizontal strip of recently used apps, as a list: a screen reader
    announces how many there are. Name it with `aria-label` or
    `aria-labelledby`. `list-style: none` drops the list role in Safari, so
    the role is set again.
  -->
  <ul
    role="list"
    :class="
      cn(
        'm-0 flex list-none gap-3 overflow-x-auto p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
        props.class
      )
    "
  >
    <slot />
  </ul>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

/* One recent app: a list item holding the button the attributes apply to. */
defineOptions({ inheritAttrs: false })

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /**
     * How an `<img>` inside fills the tile: `cover` crops it, `contain`
     * shows all of it, for a logo that must not be cut.
     */
    fit?: "cover" | "contain"
  }>(),
  { fit: "cover" }
)
</script>

<template>
  <li class="flex shrink-0">
    <button
      type="button"
      v-bind="$attrs"
      :class="
        cn(
          'inline-flex h-12 w-12 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-[14px] border-0 bg-newt-bg-base p-0 text-newt-text-secondary transition-[filter] duration-fast ease-newt',
          'hover:brightness-110',
          'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link',
          '[&>img]:h-full [&>img]:w-full [&>svg]:h-6 [&>svg]:w-6',
          props.fit === 'contain'
            ? '[&>img]:object-contain'
            : '[&>img]:object-cover',
          props.class
        )
      "
    >
      <slot />
    </button>
  </li>
</template>
<script setup lang="ts">
import type { HTMLAttributes, VNode } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()

defineSlots<{
  /** The artwork across the top. An `<img>` fills it and is cropped. */
  art?: () => VNode[]
  /** The row below the art, such as an icon, the app name and a line. */
  footer?: () => VNode[]
}>()
</script>

<template>
  <!-- A promoted app: art on top, a footer with its name below. -->
  <button
    type="button"
    :class="
      cn(
        'flex w-full shrink-0 cursor-pointer flex-col overflow-hidden rounded-[var(--newt-radius-md)] border-0 bg-newt-bg-elevated p-0 text-start text-newt-text-primary transition-colors duration-fast ease-newt',
        'hover:bg-newt-bg-hover',
        'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link',
        props.class
      )
    "
  >
    <span
      v-if="$slots.art"
      class="block aspect-video overflow-hidden bg-newt-bg-base [&>img]:block [&>img]:h-full [&>img]:w-full [&>img]:object-cover"
    >
      <slot name="art" />
    </span>
    <span v-if="$slots.footer" class="flex min-w-0 items-center gap-3 p-3">
      <slot name="footer" />
    </span>
  </button>
</template>
import { cva, type VariantProps } from "class-variance-authority"

export { default as AppLauncher } from "./AppLauncher.vue"
export { default as AppLauncherHandle } from "./AppLauncherHandle.vue"
export { default as AppLauncherHeader } from "./AppLauncherHeader.vue"
export { default as AppLauncherHeaderTitle } from "./AppLauncherHeaderTitle.vue"
export { default as AppLauncherBack } from "./AppLauncherBack.vue"
export { default as AppLauncherSearch } from "./AppLauncherSearch.vue"
export { default as AppLauncherSearchInput } from "./AppLauncherSearchInput.vue"
export { default as AppLauncherBody } from "./AppLauncherBody.vue"
export { default as AppLauncherSection } from "./AppLauncherSection.vue"
export { default as AppLauncherSectionHeader } from "./AppLauncherSectionHeader.vue"
export { default as AppLauncherSectionTitle } from "./AppLauncherSectionTitle.vue"
export { default as AppLauncherViewMore } from "./AppLauncherViewMore.vue"
export { default as AppLauncherList } from "./AppLauncherList.vue"
export { default as AppLauncherItem } from "./AppLauncherItem.vue"
export { default as AppLauncherItemIcon } from "./AppLauncherItemIcon.vue"
export { default as AppLauncherRecents } from "./AppLauncherRecents.vue"
export { default as AppLauncherRecent } from "./AppLauncherRecent.vue"
export { default as AppLauncherPromoCard } from "./AppLauncherPromoCard.vue"

export const appLauncherVariants = cva(
  "flex w-full flex-col overflow-hidden border border-newt-border bg-newt-bg-surface text-newt-text-primary shadow-elevation-high",
  {
    variants: {
      variant: {
        /* The desktop popout, at a fixed size. */
        popout:
          "h-[min(680px,calc(100dvh-2rem))] max-w-[504px] rounded-[var(--newt-radius-md)]",
        /* The bottom sheet: full width, rising from the bottom edge. */
        sheet:
          "h-[var(--newt-app-launcher-sheet-height,90dvh)] max-w-none rounded-t-[var(--newt-radius-lg)] border-b-0",
      },
    },
    defaultVariants: { variant: "popout" },
  }
)

export type AppLauncherVariants = VariantProps<typeof appLauncherVariants>

Update the import paths

The files import @/lib/utils and sibling components through the aliases in your components.json. Point them at wherever those live in your project.

No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds App Launcher to your React project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.

No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds App Launcher to your Vue project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.

Usage

import { AppLauncher } from "@/components/ui/app-launcher"

export function Example() {
  return <AppLauncher />
}
<script setup lang="ts">
import { AppLauncher, AppLauncherHandle, AppLauncherHeader, AppLauncherHeaderTitle, AppLauncherBack, AppLauncherSearch, AppLauncherSearchInput, AppLauncherBody, AppLauncherSection, AppLauncherSectionHeader, AppLauncherSectionTitle, AppLauncherViewMore, AppLauncherList, AppLauncherItem, AppLauncherItemIcon, AppLauncherRecents, AppLauncherRecent, AppLauncherPromoCard } from "@/components/ui/app-launcher"
</script>

<template>
  <AppLauncher />
</template>

The preview above is an inline launcher: it stays in the page and does not move focus. Without inline, AppLauncher is a dialog.

Examples

Bottom sheet

Pass variant="sheet" for a phone. The sheet fills the width, drops its bottom border and rounds its top corners. Its height is --newt-app-launcher-sheet-height, which defaults to 90dvh. Set the property on the launcher or on an ancestor to change it.

Give AppLauncherHandle a label when the handle changes the sheet. It then renders a button with that name, so Enter and Space press it. Pass expanded to report the state as aria-expanded. Without a label, the handle is a decorative grip that assistive technology skips.

The example below is a modal dialog. Press the handle to change the height, type to filter the apps, and press Escape to close it. The search field is controlled: value and onValueChange in React, v-model in Vue.

Root class newt-app-launcher
"use client"

import * as React from "react"

import {
  AppLauncher,
  AppLauncherBody,
  AppLauncherHandle,
  AppLauncherItem,
  AppLauncherItemIcon,
  AppLauncherList,
  AppLauncherSearch,
  AppLauncherSearchInput,
  AppLauncherSection,
  AppLauncherSectionHeader,
  AppLauncherSectionTitle,
} from "@/registry/bases/newt/ui/app-launcher"
import { Button } from "@/registry/bases/newt/ui/button"

const APPS = [
  {
    name: "Moderation",
    description: "Bans, timeouts and audit logs.",
    path: "M12 2 4 5v7c0 5 3.4 8.4 8 10 4.6-1.6 8-5 8-10V5l-8-3Z",
  },
  {
    name: "Poll Night",
    description: "Run a quick poll in any channel.",
    path: "M4 4h16v12H8l-4 4V4Z",
  },
  {
    name: "Reminders",
    description: "Schedule a message for later.",
    path: "M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm1 4v5l4 2-1 1.7-5-2.7V7h2Z",
  },
]

export default function AppLauncherSheetDemo() {
  const [open, setOpen] = React.useState(false)
  const [expanded, setExpanded] = React.useState(false)
  const [query, setQuery] = React.useState("")

  const matches = APPS.filter((app) =>
    app.name.toLowerCase().includes(query.trim().toLowerCase())
  )

  return (
    <div className="relative flex h-[480px] w-full max-w-sm items-center justify-center overflow-hidden rounded-md bg-newt-bg-elevated">
      <Button variant="secondary" onClick={() => setOpen(true)}>
        Open Apps
      </Button>

      {open ? (
        <AppLauncher
          variant="sheet"
          modal
          label="Apps"
          onClose={() => setOpen(false)}
          className={
            expanded
              ? "absolute inset-x-0 bottom-0 [--newt-app-launcher-sheet-height:100%]"
              : "absolute inset-x-0 bottom-0 [--newt-app-launcher-sheet-height:62%]"
          }
        >
          <AppLauncherHandle
            label="Expand the sheet"
            expanded={expanded}
            onClick={() => setExpanded((value) => !value)}
          />

          <AppLauncherSearch>
            <AppLauncherSearchInput
              placeholder="Search Apps & Commands"
              aria-label="Search apps and commands"
              value={query}
              onValueChange={setQuery}
            />
          </AppLauncherSearch>

          <AppLauncherBody>
            <AppLauncherSection aria-label="Apps in this server">
              <AppLauncherSectionHeader>
                <AppLauncherSectionTitle>
                  Apps in this Server
                </AppLauncherSectionTitle>
              </AppLauncherSectionHeader>
              {matches.length > 0 ? (
                <AppLauncherList>
                  {matches.map((app) => (
                    <AppLauncherItem
                      key={app.name}
                      name={app.name}
                      description={app.description}
                      icon={
                        <AppLauncherItemIcon>
                          <svg viewBox="0 0 24 24" fill="currentColor">
                            <path d={app.path} />
                          </svg>
                        </AppLauncherItemIcon>
                      }
                    />
                  ))}
                </AppLauncherList>
              ) : (
                <p className="m-0 px-0.5 text-sm text-newt-text-muted">
                  No apps match.
                </p>
              )}
            </AppLauncherSection>
          </AppLauncherBody>
        </AppLauncher>
      ) : null}
    </div>
  )
}
<script setup lang="ts">
import { computed, ref } from "vue"
import {
  AppLauncher,
  AppLauncherBody,
  AppLauncherHandle,
  AppLauncherItem,
  AppLauncherItemIcon,
  AppLauncherList,
  AppLauncherSearch,
  AppLauncherSearchInput,
  AppLauncherSection,
  AppLauncherSectionHeader,
  AppLauncherSectionTitle,
} from "~~/registry/bases/newt/ui/app-launcher"
import { Button } from "~~/registry/bases/newt/ui/button"

const apps = [
  {
    name: "Moderation",
    description: "Bans, timeouts and audit logs.",
    path: "M12 2 4 5v7c0 5 3.4 8.4 8 10 4.6-1.6 8-5 8-10V5l-8-3Z",
  },
  {
    name: "Poll Night",
    description: "Run a quick poll in any channel.",
    path: "M4 4h16v12H8l-4 4V4Z",
  },
  {
    name: "Reminders",
    description: "Schedule a message for later.",
    path: "M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm1 4v5l4 2-1 1.7-5-2.7V7h2Z",
  },
]

const open = ref(false)
const expanded = ref(false)
const query = ref("")

const matches = computed(() =>
  apps.filter((app) =>
    app.name.toLowerCase().includes(query.value.trim().toLowerCase())
  )
)
</script>

<template>
  <div
    class="relative flex h-[480px] w-full max-w-sm items-center justify-center overflow-hidden rounded-md bg-newt-bg-elevated"
  >
    <Button variant="secondary" @click="open = true">Open Apps</Button>

    <AppLauncher
      v-if="open"
      variant="sheet"
      modal
      label="Apps"
      :class="
        expanded
          ? 'absolute inset-x-0 bottom-0 [--newt-app-launcher-sheet-height:100%]'
          : 'absolute inset-x-0 bottom-0 [--newt-app-launcher-sheet-height:62%]'
      "
      @close="open = false"
    >
      <AppLauncherHandle
        label="Expand the sheet"
        :expanded="expanded"
        @click="expanded = !expanded"
      />

      <AppLauncherSearch>
        <AppLauncherSearchInput
          v-model="query"
          placeholder="Search Apps & Commands"
          aria-label="Search apps and commands"
        />
      </AppLauncherSearch>

      <AppLauncherBody>
        <AppLauncherSection aria-label="Apps in this server">
          <AppLauncherSectionHeader>
            <AppLauncherSectionTitle
              >Apps in this Server</AppLauncherSectionTitle
            >
          </AppLauncherSectionHeader>
          <AppLauncherList v-if="matches.length > 0">
            <AppLauncherItem
              v-for="app in matches"
              :key="app.name"
              :name="app.name"
              :description="app.description"
            >
              <template #icon>
                <AppLauncherItemIcon>
                  <svg viewBox="0 0 24 24" fill="currentColor">
                    <path :d="app.path" />
                  </svg>
                </AppLauncherItemIcon>
              </template>
            </AppLauncherItem>
          </AppLauncherList>
          <p v-else class="m-0 px-0.5 text-sm text-newt-text-muted">
            No apps match.
          </p>
        </AppLauncherSection>
      </AppLauncherBody>
    </AppLauncher>
  </div>
</template>

AppLauncher is built on Radix Dialog in React and Reka UI Dialog in Vue. It renders in place, with no portal and no overlay, so your layout decides where it sits. It is open for as long as it is mounted.

When it mounts, focus moves to its first control. Tab cycles through the controls of the launcher. Escape calls onClose (@close in Vue). Unmount the launcher in answer. Focus then returns to the element that held it before.

Add modal when the launcher covers the page. The rest of the page is then out of use. Assistive technology skips it, focus cannot move to it, and a press on it asks to close the launcher.

Drill-in view

A view that opens from an app has its own header. AppLauncherHeaderTitle takes the free width and centres in it. Put a spacer as wide as the back control after it, so the title sits in the centre of the header.

AppLauncherPromoCard draws a promoted app: art on top, a footer below. AppLauncherItem takes trailing for content after the text, such as a chevron. The item is a row that holds its button and, beside it, the trailing content. A press on a chevron presses the button. A control in trailing, such as a visibility toggle, keeps its own presses. className styles the row, and the ref and other props go to the button. variant="tile" puts the icon above the name, inside an AppLauncherList with variant="grid".

An <img> in AppLauncherItemIcon or AppLauncherRecent covers the icon and is cropped. Pass fit="contain" for a logo that must not be cut, as the first tile does.

Root class newt-app-launcher
import {
  AppLauncher,
  AppLauncherBack,
  AppLauncherBody,
  AppLauncherHeader,
  AppLauncherHeaderTitle,
  AppLauncherItem,
  AppLauncherItemIcon,
  AppLauncherList,
  AppLauncherPromoCard,
  AppLauncherSection,
  AppLauncherSectionHeader,
  AppLauncherSectionTitle,
} from "@/registry/bases/newt/ui/app-launcher"

const ART =
  "data:image/svg+xml;utf8," +
  encodeURIComponent(
    `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 90">
      <defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
        <stop offset="0" stop-color="#5865f2"/><stop offset="1" stop-color="#eb459e"/>
      </linearGradient></defs>
      <rect width="160" height="90" fill="url(#g)"/>
      <path d="M80 22 56 31v21c0 15 10 25 24 30 14-5 24-15 24-30V31l-24-9Z" fill="#fff" fill-opacity=".85"/>
    </svg>`
  )

/* A wide logo: `fit="contain"` shows all of it in the square icon. */
const WIDE_LOGO =
  "data:image/svg+xml;utf8," +
  encodeURIComponent(
    `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 40">
      <rect width="120" height="40" rx="8" fill="#23a55a"/>
      <circle cx="20" cy="20" r="10" fill="#fff"/>
      <rect x="38" y="15" width="70" height="10" rx="5" fill="#fff"/>
    </svg>`
  )

const ShieldIcon = () => (
  <svg viewBox="0 0 24 24" fill="currentColor">
    <path d="M12 2 4 5v7c0 5 3.4 8.4 8 10 4.6-1.6 8-5 8-10V5l-8-3Z" />
  </svg>
)

const Chevron = () => (
  <svg viewBox="0 0 20 20" fill="currentColor" className="rtl:-scale-x-100">
    <path d="m7.3 4.3 5.7 5.7-5.7 5.7-1.4-1.4 4.3-4.3-4.3-4.3 1.4-1.4Z" />
  </svg>
)

export default function AppLauncherDrillInDemo() {
  return (
    <AppLauncher inline label="Moderation" className="h-[560px]">
      <AppLauncherHeader>
        <AppLauncherBack aria-label="Back">
          <svg
            viewBox="0 0 20 20"
            className="h-5 w-5 rtl:-scale-x-100"
            fill="currentColor"
          >
            <path d="M8.7 3.3 2 10l6.7 6.7 1.4-1.4L5.8 11H18V9H5.8l4.3-4.3-1.4-1.4Z" />
          </svg>
        </AppLauncherBack>
        <AppLauncherHeaderTitle>Moderation</AppLauncherHeaderTitle>
        {/* As wide as the back control, so the title sits in the centre. */}
        <span aria-hidden="true" className="w-8 shrink-0" />
      </AppLauncherHeader>

      <AppLauncherBody>
        <AppLauncherPromoCard
          art={<img src={ART} alt="" />}
          footer={
            <>
              <AppLauncherItemIcon round>
                <ShieldIcon />
              </AppLauncherItemIcon>
              <span className="flex min-w-0 flex-col gap-0.5">
                <span className="truncate text-base font-medium">
                  Moderation
                </span>
                <span className="truncate text-sm text-newt-text-muted">
                  Keep every channel calm.
                </span>
              </span>
            </>
          }
        />

        <AppLauncherSection aria-label="Commands">
          <AppLauncherSectionHeader>
            <AppLauncherSectionTitle>Commands</AppLauncherSectionTitle>
          </AppLauncherSectionHeader>
          <AppLauncherList>
            <AppLauncherItem
              name="/ban"
              description="Remove a member from the server."
              trailing={<Chevron />}
            />
            <AppLauncherItem
              name="/timeout"
              description="Mute a member for a while."
              trailing={<Chevron />}
            />
          </AppLauncherList>
        </AppLauncherSection>

        <AppLauncherSection aria-label="More from this developer">
          <AppLauncherSectionHeader>
            <AppLauncherSectionTitle>
              More from this developer
            </AppLauncherSectionTitle>
          </AppLauncherSectionHeader>
          <AppLauncherList variant="grid">
            <AppLauncherItem
              variant="tile"
              name="Audit Log"
              icon={
                <AppLauncherItemIcon fit="contain">
                  <img src={WIDE_LOGO} alt="" />
                </AppLauncherItemIcon>
              }
            />
            <AppLauncherItem
              variant="tile"
              name="Shield"
              icon={
                <AppLauncherItemIcon round>
                  <ShieldIcon />
                </AppLauncherItemIcon>
              }
            />
            <AppLauncherItem
              variant="tile"
              name="Reminders"
              icon={
                <AppLauncherItemIcon>
                  <svg viewBox="0 0 24 24" fill="currentColor">
                    <path d="M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm1 4v5l4 2-1 1.7-5-2.7V7h2Z" />
                  </svg>
                </AppLauncherItemIcon>
              }
            />
          </AppLauncherList>
        </AppLauncherSection>
      </AppLauncherBody>
    </AppLauncher>
  )
}
<script setup lang="ts">
import {
  AppLauncher,
  AppLauncherBack,
  AppLauncherBody,
  AppLauncherHeader,
  AppLauncherHeaderTitle,
  AppLauncherItem,
  AppLauncherItemIcon,
  AppLauncherList,
  AppLauncherPromoCard,
  AppLauncherSection,
  AppLauncherSectionHeader,
  AppLauncherSectionTitle,
} from "~~/registry/bases/newt/ui/app-launcher"

const art =
  "data:image/svg+xml;utf8," +
  encodeURIComponent(
    `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 90">
      <defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
        <stop offset="0" stop-color="#5865f2"/><stop offset="1" stop-color="#eb459e"/>
      </linearGradient></defs>
      <rect width="160" height="90" fill="url(#g)"/>
      <path d="M80 22 56 31v21c0 15 10 25 24 30 14-5 24-15 24-30V31l-24-9Z" fill="#fff" fill-opacity=".85"/>
    </svg>`
  )

/* A wide logo: `fit="contain"` shows all of it in the square icon. */
const wideLogo =
  "data:image/svg+xml;utf8," +
  encodeURIComponent(
    `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 40">
      <rect width="120" height="40" rx="8" fill="#23a55a"/>
      <circle cx="20" cy="20" r="10" fill="#fff"/>
      <rect x="38" y="15" width="70" height="10" rx="5" fill="#fff"/>
    </svg>`
  )

const shieldPath = "M12 2 4 5v7c0 5 3.4 8.4 8 10 4.6-1.6 8-5 8-10V5l-8-3Z"
const chevronPath = "m7.3 4.3 5.7 5.7-5.7 5.7-1.4-1.4 4.3-4.3-4.3-4.3 1.4-1.4Z"
const commands = [
  { name: "/ban", description: "Remove a member from the server." },
  { name: "/timeout", description: "Mute a member for a while." },
]
</script>

<template>
  <AppLauncher inline label="Moderation" class="h-[560px]">
    <AppLauncherHeader>
      <AppLauncherBack aria-label="Back">
        <svg
          viewBox="0 0 20 20"
          class="h-5 w-5 rtl:-scale-x-100"
          fill="currentColor"
        >
          <path
            d="M8.7 3.3 2 10l6.7 6.7 1.4-1.4L5.8 11H18V9H5.8l4.3-4.3-1.4-1.4Z"
          />
        </svg>
      </AppLauncherBack>
      <AppLauncherHeaderTitle>Moderation</AppLauncherHeaderTitle>
      <!-- As wide as the back control, so the title sits in the centre. -->
      <span aria-hidden="true" class="w-8 shrink-0" />
    </AppLauncherHeader>

    <AppLauncherBody>
      <AppLauncherPromoCard>
        <template #art>
          <img :src="art" alt="" />
        </template>
        <template #footer>
          <AppLauncherItemIcon round>
            <svg viewBox="0 0 24 24" fill="currentColor">
              <path :d="shieldPath" />
            </svg>
          </AppLauncherItemIcon>
          <span class="flex min-w-0 flex-col gap-0.5">
            <span class="truncate text-base font-medium">Moderation</span>
            <span class="truncate text-sm text-newt-text-muted">
              Keep every channel calm.
            </span>
          </span>
        </template>
      </AppLauncherPromoCard>

      <AppLauncherSection aria-label="Commands">
        <AppLauncherSectionHeader>
          <AppLauncherSectionTitle>Commands</AppLauncherSectionTitle>
        </AppLauncherSectionHeader>
        <AppLauncherList>
          <AppLauncherItem
            v-for="command in commands"
            :key="command.name"
            :name="command.name"
            :description="command.description"
          >
            <template #trailing>
              <svg
                viewBox="0 0 20 20"
                fill="currentColor"
                class="rtl:-scale-x-100"
              >
                <path :d="chevronPath" />
              </svg>
            </template>
          </AppLauncherItem>
        </AppLauncherList>
      </AppLauncherSection>

      <AppLauncherSection aria-label="More from this developer">
        <AppLauncherSectionHeader>
          <AppLauncherSectionTitle>
            More from this developer
          </AppLauncherSectionTitle>
        </AppLauncherSectionHeader>
        <AppLauncherList variant="grid">
          <AppLauncherItem variant="tile" name="Audit Log">
            <template #icon>
              <AppLauncherItemIcon fit="contain">
                <img :src="wideLogo" alt="" />
              </AppLauncherItemIcon>
            </template>
          </AppLauncherItem>
          <AppLauncherItem variant="tile" name="Shield">
            <template #icon>
              <AppLauncherItemIcon round>
                <svg viewBox="0 0 24 24" fill="currentColor">
                  <path :d="shieldPath" />
                </svg>
              </AppLauncherItemIcon>
            </template>
          </AppLauncherItem>
          <AppLauncherItem variant="tile" name="Reminders">
            <template #icon>
              <AppLauncherItemIcon>
                <svg viewBox="0 0 24 24" fill="currentColor">
                  <path
                    d="M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm1 4v5l4 2-1 1.7-5-2.7V7h2Z"
                  />
                </svg>
              </AppLauncherItemIcon>
            </template>
          </AppLauncherItem>
        </AppLauncherList>
      </AppLauncherSection>
    </AppLauncherBody>
  </AppLauncher>
</template>

API reference

AppLauncher

PropType
variant?"popout" | "sheet"

`popout` is the desktop launcher at a fixed size. `sheet` is the bottom sheet, with the height of `--newt-app-launcher-sheet-height`.

Type"popout" | "sheet"
Default"popout"
inline?boolean | undefined

Render the launcher in the page: no dialog role, and focus stays where it is. Use it for a launcher that is always on screen, such as a showcase.

Typeboolean | undefined
Defaultfalse
modal?boolean | undefined

Take the page behind the launcher out of use: it is hidden from assistive technology, focus cannot move to it, and a press on it closes the launcher. Has no effect on an `inline` launcher.

Typeboolean | undefined
Defaultfalse
label?string | undefined

The accessible name of the launcher. Without it, name the launcher with `aria-label` or `aria-labelledby`.

Typestring | undefined
onClose / @close?() => void

The user asks to close the dialog: Escape, or a press outside a `modal` one.

Type() => void

AppLauncherHandle

PropType
label?string | undefined

The accessible name of the handle. With it, the handle is a button. Without it, the handle is a decorative grip.

Typestring | undefined
expanded?boolean | undefined

Whether the sheet is expanded, reported as `aria-expanded` on the button.

Typeboolean | undefined

AppLauncherSearchInput

PropType
value / v-model?string | undefined

The query. Bind it to control the field.

Typestring | undefined
onValueChange?(value: string) => void

React only. Called with the text of the field on each change, after `onChange`.

Type(value: string) => void

AppLauncherList

PropType
variant?"stack" | "grid"

`stack` puts rows behind one rounded surface. `grid` lays out tile items in columns.

Type"stack" | "grid"
Default"stack"

AppLauncherItem

PropType
name?string

The name of the app.

Typestring
description?string | undefined

A short line under the name.

Typestring | undefined
icon / #icon?React.ReactNode | slot

Icon for the app; pair with `AppLauncherItemIcon`.

TypeReact.ReactNode | slot
trailing / #trailing?React.ReactNode | slot

Content after the text, such as a chevron or a visibility toggle. It sits beside the item button, so it can hold a control.

TypeReact.ReactNode | slot
variant?"row" | "tile"

`row` puts the icon beside the text. `tile` puts it above, for a `grid` list.

Type"row" | "tile"
Default"row"
promoted?boolean | undefined

Marks a paid placement, as the client does for promoted apps.

Typeboolean | undefined
promotedLabel?string

Text of the `promoted` badge. It is also part of the button's name.

Typestring
Default"Promoted"

AppLauncherItemIcon

PropType
round?boolean | undefined

Bots use circular avatars; games and activities keep the squircle.

Typeboolean | undefined
fit?"cover" | "contain"

How an `<img>` inside fills the icon. `cover` crops it; `contain` shows all of it.

Type"cover" | "contain"
Default"cover"

AppLauncherRecent

PropType
fit?"cover" | "contain"

How an `<img>` inside fills the tile. `cover` crops it; `contain` shows all of it.

Type"cover" | "contain"
Default"cover"

AppLauncherPromoCard

PropType
art / #art?React.ReactNode | slot

The artwork across the top, at 16:9. An `<img>` fills it and is cropped.

TypeReact.ReactNode | slot
footer / #footer?React.ReactNode | slot

The row below the art, such as an icon, the name and a line.

TypeReact.ReactNode | slot

The registry exports AppLauncher, AppLauncherHandle, AppLauncherHeader, AppLauncherHeaderTitle, AppLauncherBack, AppLauncherSearch, AppLauncherSearchInput, AppLauncherBody, AppLauncherSection, AppLauncherSectionHeader, AppLauncherSectionTitle, AppLauncherViewMore, AppLauncherList, AppLauncherItem, AppLauncherItemIcon, AppLauncherRecents, AppLauncherRecent, AppLauncherPromoCard, and appLauncherVariants. Parts without a table accept the native attributes for the element they render; React uses className, while Vue uses class and fallthrough attributes.

Accessibility

Give the launcher a label. A dialog reads it when it opens. An inline launcher with a label is a region landmark; without one it is a plain div.

The Promoted badge takes its text from promotedLabel. Translating labels lists every English default.

Tab cycles through the controls of a dialog, and Escape leaves it. A dialog that is not modal leaves the page beside it in use. Use modal for a sheet that covers the page, so focus cannot move to content the user cannot see.

Do not wrap a dialog AppLauncher in a Drawer or a Modal. That nests one dialog in another. Put an inline launcher inside them when you want their overlay.

A handle that changes the sheet needs a label, so it is a button with a name. Keep expanded in step with the sheet. A drag gesture alone fails keyboard users; the button gives them the same action.

AppLauncherRecents is a list, so a screen reader announces how many recent apps there are. Name it with aria-label or aria-labelledby, and give every AppLauncherRecent an aria-label. Label the search field, and keep alt="" on art and icons that the text beside them already names.

In the plain HTML and CSS distribution, app-launcher.js gives a launcher marked data-newt-app-launcher the same behaviour. A data-newt-app-launcher-close control closes it, and aria-modal="true" makes it modal. The launcher fires newt:close before it leaves the page; cancel the event to close it your own way.

With several launchers open, Escape closes the newest one that holds focus. An Escape that a control inside already handled with preventDefault() closes nothing, and the launcher marks the Escape it handles the same way. Tab skips controls inside hidden content.

Tokens

App Launcher reads its colours, radii and motion from the --newt-* tokens installed with the library. Override a token and every component that reads it follows, including this one — see the token layer. In the plain HTML and CSS distribution the same component is newt-app-launcher.

  • --newt-border
  • --newt-radius-md
  • --newt-bg-surface
  • --newt-shadow-elevation-high
  • --newt-text-primary
  • --newt-radius-lg
  • --newt-radius-full
  • --newt-text-muted
  • --newt-text-link
  • --newt-bg-elevated
  • --newt-text-secondary
  • --newt-duration-fast
  • --newt-ease
  • --newt-bg-hover
  • --newt-bg-input
  • --newt-brand
  • --newt-radius-sm
  • --newt-bg-base
  • --newt-dir