@frigear-nu/ui

中文文档
0.2.6发布于 2026/11/12MITTypeScriptES Module构建来源已验证近 30 天下载 4166

Shared UI components and composables for Frigear Nuxt applications, built on Nuxt UI.

原始使用文档
文档目录3 节
  1. App shell
  2. Page patterns
  3. Inputs

@frigear-nu/ui

Shared UI components, composables and helpers for Frigear Nuxt applications, built on Nuxt UI. Registers its components globally (no prefix) and auto-imports its composables and helpers. It brings patterns, not a theme: every card uses the same bg-elevated/50 ring ring-default rounded-lg surface and the host's Nuxt UI colours.

Built-in strings come from @nuxtjs/i18n when installed (patterns.*, actions.*; en and da included), with English fallbacks; every one of them can be overridden by a prop.

App shell

AppShell is the dashboard shell of the app areas (admin, account); an area layout wraps its pages in it:

<AppShell
  id="admin"
  :title="t('title', 'Administration')"
  home="/admin"
  :navigation="navigation"
  :nav-label="t('nav.label', 'Admin navigation')"
  :search-groups="searchGroups"
  :back-to="{ to: '/', label: t('backToSite', 'Back to the site') }"
>
  <template #sidebar-footer="{ collapsed }">
    <AccountMenu block :collapsed="collapsed" />
  </template>
  <slot />
</AppShell>
  • id keys the dashboard-sidebar-<id> cookie (collapse, width); one per area. home and backTo.to are raw paths, the shell adds the locale prefix.
  • navigation is a list of UNavigationMenu groups (type: 'label' rows head a group). The navbar shows a muted eyebrow, title › active section, never a heading: the page renders the only <h1> through PageHeading.
  • searchGroups adds the ⌘K button and palette (without the colour-mode group); leave it out for no search.
  • The body is centred at max-w-7xl; wide or definePageMeta({ wide: true }) makes it full width.
  • The document title defaults to the active section (else title); a page's own useHead wins.
  • Slots: brand, sidebar-top, sidebar-footer (all get { collapsed }), navbar-left (replaces the eyebrow), navbar-right (defaults to LanguageSelect when the app has one and more than one locale), default.
  • The light app theme is utility classes on the shell (bg-default body, bg-elevated/25 sidebar, a primary-coloured brand tile); hosts can target [data-area=app].

Page patterns

ComponentUse
PageHeadingTitle block of an app page: breadcrumb (array) or eyebrow line (string), #badge, description, meta row, #actions
PageSectionSwitcherFull-width button naming the current section, with a menu of all sections (mobile section navigation)
PageTabsTabs under a heading: links (to, route decides) or state (v-model + value)
SectionCardA titled card for one section (form, key facts); flush for tables and lists
TableCardThe surface a UTable sits in (:ui="tableUi()"), with #header and #footer (total, pagination)
RowMenuThe ⋯ menu of a table row or heading; order Open → edits → destructive group
StatCardA number with a label, tinted icon and hint; links to its list with to
ListCardA short divided list with a "View all" link
DescriptionListLabel/value rows; empty values read "Not set"; slot per key
PageToolbarSearch and filters above a table, #right for counts
FormRowA UFormField as a settings row (label and hint left, control right, stacked below sm) for inline forms in a SectionCard; parent divide-y divide-default
FormSlideoverCreate/edit form in a slideover with Cancel + submit (form="<formId>"); works with useOverlay
ConfirmDialog / useConfirmDialog()Confirmation before destructive actions
ComposableUse
useAction(){ busy, run(fn, { success?, error? }) }: toasts success, toasts and swallows errors
useErrorToast()(e, title?) => void: an error as a red toast
useCopyToClipboard(){ copy(text, message?) } with a "Copied" toast
useFormat(){ date, dateTime, time, dateRange, money } in the active locale and the app time zone (appConfig.frigearUi.timeZone, e.g. Europe/Copenhagen), so server and client render the same text
useLocaleLink(){ localize, strip, isActive }: locale-prefix aware paths (identity without i18n)
useNavLinks(items, { exact })Menu items to UNavigationMenu links with localised to and active
Helper (@frigear-nu/ui/utils)Use
errorMessage(e, fallback), errorToToast(e, overrides?)The useful message of a $fetch/createError error
formatDate, formatDateTime, formatTime, formatDateRangeIntl date formatting (value, locale?, options?)
statusColor(status, overrides?)Badge colour of a status (published/active/paid → success, pending → warning, failed → error)
stripLocale(path, codes)A path without its /<locale> prefix
surfaceClass, tableUi(overrides?)The card surface and a UTable :ui for TableCard

Types (DescriptionItem, PageTabItem, StatusColor, …) are exported from @frigear-nu/ui/types.

Inputs

CurrencyInput, MoneyInput, DateInput, IntervalInput, TagInput, UrlInput, IconInput, SwitchToggle, MarkdownTextarea, TranslatedInput; MonacoCodeEditor only when the host installs nuxt-monaco-editor.

See the documentation and the playground.

版本与发布记录

@frigear-nu/ui 共发布 20 个版本,首次发布于 2026/10/11;过去 12 个月发布了 20 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.6latest2026/11/123 天前
0.2.52026/11/0511 天前
0.2.42026/11/0411 天前
0.2.32026/11/0411 天前
0.2.22026/11/0312 天前
0.2.12026/11/0312 天前

关于 @frigear-nu/ui 的常见问题

@frigear-nu/ui 是什么?

Shared UI components and composables for Frigear Nuxt applications, built on Nuxt UI.

如何安装 @frigear-nu/ui?

在项目目录运行 npm install @frigear-nu/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(3.x)、nuxt(^4.6.4)、@nuxt/ui(^4.12.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@frigear-nu/ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@frigear-nu/ui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@frigear-nu/ui 可以商用吗?

@frigear-nu/ui 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@frigear-nu/ui 的下载量有多少?

根据 npm 官方下载统计,@frigear-nu/ui 在 2026/10/16 – 2026/11/14 这 30 天内被下载 4,166 次,日均约 139 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frigear-nu/ui 还在维护吗?

最新版本 0.2.6 发布于 2026/11/12(3 天前);至今共发布 20 个版本,其中过去 12 个月发布了 20 个;首次发布于 2026/10/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。