@fiscozen/action

中文文档
3.0.1发布于 2026/04/30MITES Module近 30 天下载 2309

Design System Action component

原始使用文档
文档目录27 节
  1. Features
  2. Installation
  3. Basic Usage
  4. FzAction as Button
  5. FzAction as Link
  6. FzActionList with Multiple Actions
  7. FzActionSection for Grouping
  8. Props
  9. FzAction
  10. FzActionList
  11. FzActionSection
  12. Events
  13. FzAction
  14. Accessibility
  15. ARIA Roles
  16. Keyboard Navigation
  17. Screen Reader Support
  18. Examples
  19. Icon-Only Action
  20. Action with Icons
  21. Action with SubLabel
  22. Disabled Action
  23. Readonly Action
  24. Text Truncation
  25. Environment Variants
  26. Notes
  27. Related Components

@fiscozen/action

Versatile action components for building interactive lists, menus, and selectable options.

Features

  • FzAction: Flexible action component that can render as button or link
  • FzActionList: Container for organizing multiple actions
  • FzActionSection: Section separator with label for grouping actions
  • Multiple variants: textLeft, textCenter, onlyIcon
  • Environment-specific styling: backoffice (compact) and frontoffice (spacious)
  • Full accessibility support with configurable ARIA roles
  • Keyboard navigation and focus management
  • Disabled and readonly states
  • Text truncation with ellipsis
  • Icon positioning (left, right, or icon-only)

Installation

npm install @fiscozen/action

Basic Usage

FzAction as Button

<script setup>
import { FzAction } from '@fiscozen/action'
</script>

<template>
  <FzAction
    type="action"
    variant="textLeft"
    label="Click me"
    @click="handleClick"
  />
</template>
<script setup>
import { FzAction } from '@fiscozen/action'
</script>

<template>
  <FzAction
    type="link"
    variant="textLeft"
    label="Go to page"
    to="/page"
  />
</template>

FzActionList with Multiple Actions

<script setup>
import { FzActionList, FzAction } from '@fiscozen/action'
</script>

<template>
  <FzActionList>
    <FzAction type="action" variant="textLeft" label="Edit" />
    <FzAction type="action" variant="textLeft" label="Delete" />
    <FzAction type="action" variant="textLeft" label="Share" />
  </FzActionList>
</template>

FzActionSection for Grouping

<script setup>
import { FzActionList, FzAction, FzActionSection } from '@fiscozen/action'
</script>

<template>
  <FzActionList>
    <FzActionSection label="File" />
    <FzAction type="action" variant="textLeft" label="New" />
    <FzAction type="action" variant="textLeft" label="Open" />
    
    <FzActionSection label="Edit" />
    <FzAction type="action" variant="textLeft" label="Cut" />
    <FzAction type="action" variant="textLeft" label="Copy" />
  </FzActionList>
</template>

Props

FzAction

PropTypeDefaultDescription
type'action' | 'link''action'Component type (button or link)
variant'textLeft' | 'textCenter' | 'onlyIcon''textLeft'Layout variant
environment'backoffice' | 'frontoffice''backoffice'Environment styling (compact vs spacious)
labelstring-Main label text
subLabelstring-Secondary text below main label
disabledbooleanfalseDisables the action
readonlybooleanfalseMakes action non-interactive but visually normal
focusedbooleanfalseVisual focus state (for keyboard navigation)
isTextTruncatedbooleanfalseEnables text truncation with ellipsis
iconLeftNamestring-FontAwesome icon name (left side)
iconLeftVariantIconVariant-FontAwesome icon variant (left side)
iconRightNamestring-FontAwesome icon name (right side)
iconRightVariantIconVariant-FontAwesome icon variant (right side)
idstring-Unique ID for ARIA relationships
rolestring-ARIA role (e.g., "option", "menuitem")
ariaSelectedboolean-ARIA selected state (for role="option")
tabindexnumber-Override tabindex value (useful for custom focus management). Default: 0 when focused and interactive, -1 otherwise

Link-specific props (when type="link"):

PropTypeDefaultDescription
toRouteLocationRaw-Router link destination (required)
replacebooleanfalseUse replace navigation
targetstring-Link target (e.g., "_blank")
externalbooleanfalseExternal link flag

Icon-only variant props (when variant="onlyIcon"):

PropTypeDefaultDescription
iconNamestring-FontAwesome icon name (required)
iconVariantIconVariant-FontAwesome icon variant (required)

FzActionList

PropTypeDefaultDescription
listClassstring''Additional CSS classes for the list
rolestring-ARIA role for the list (e.g., "listbox", "menu")
ariaLabelledbystring-ID of element that labels the list
ariaActivedescendantstring-ID of currently active descendant

FzActionSection

PropTypeDefaultDescription
labelstring''Section label text

Events

FzAction

EventPayloadDescription
clickMouseEventEmitted when action is clicked
keydownKeyboardEventEmitted on keydown (Enter/Space trigger click)

Accessibility

ARIA Roles

The role prop allows configuring the semantic role of the action:

As a listbox option (e.g., in FzSelect):

<FzActionList role="listbox" aria-labelledby="select-label">
  <FzAction
    type="action"
    variant="textLeft"
    label="Option 1"
    role="option"
    :ariaSelected="true"
  />
  <FzAction
    type="action"
    variant="textLeft"
    label="Option 2"
    role="option"
    :ariaSelected="false"
  />
</FzActionList>

As a menu:

<FzActionList role="menu">
  <FzAction
    type="action"
    variant="textLeft"
    label="Edit"
    role="menuitem"
  />
  <FzAction
    type="action"
    variant="textLeft"
    label="Delete"
    role="menuitem"
  />
</FzActionList>

Keyboard Navigation

  • Enter/Space: Triggers the action (when focused)
  • Tab: Moves focus to next focusable element
  • Arrow keys: Managed by parent component (e.g., FzSelect)

Screen Reader Support

  • aria-disabled: Always present with explicit "true" or "false" values
  • aria-selected: Added when role="option" to indicate selection state
  • aria-label: Automatically computed for icon-only variants
  • Text truncation: Full text available via title attribute

Examples

Icon-Only Action

<FzAction
  type="action"
  variant="onlyIcon"
  iconName="trash"
  iconVariant="solid"
  label="Delete"
  @click="handleDelete"
/>

Action with Icons

<FzAction
  type="action"
  variant="textLeft"
  label="Settings"
  iconLeftName="gear"
  iconLeftVariant="solid"
  iconRightName="chevron-right"
  iconRightVariant="solid"
/>

Action with SubLabel

<FzAction
  type="action"
  variant="textLeft"
  label="John Doe"
  subLabel="[email protected]"
  iconLeftName="user"
  iconLeftVariant="solid"
/>

Disabled Action

<FzAction
  type="action"
  variant="textLeft"
  label="Unavailable"
  disabled
/>

Readonly Action

<FzAction
  type="action"
  variant="textLeft"
  label="Read Only"
  readonly
/>

Text Truncation

<FzAction
  type="action"
  variant="textLeft"
  label="Very long text that will be truncated with ellipsis"
  isTextTruncated
/>

Environment Variants

<!-- Backoffice (compact) -->
<FzAction
  type="action"
  variant="textLeft"
  environment="backoffice"
  label="Compact action"
/>

<!-- Frontoffice (spacious) -->
<FzAction
  type="action"
  variant="textLeft"
  environment="frontoffice"
  label="Spacious action"
/>

Notes

  • Default environment: backoffice (compact styling)
  • Icon variants: Requires @fiscozen/icons package
  • Link functionality: Requires vue-router and @fiscozen/link package
  • ARIA roles: Optional but recommended for accessibility in complex components
  • Text truncation: Applies to both label and subLabel
  • Readonly vs Disabled: Readonly maintains normal appearance but prevents interaction; disabled shows greyed-out appearance
  • FzSelect: Uses FzAction with role="option" for dropdown options
  • FzLink: Base link component used when type="link"
  • FzIcon: Icon component from @fiscozen/icons

版本与发布记录

@fiscozen/action 共发布 7 个版本,首次发布于 2025/12/15;过去 12 个月发布了 7 个版本。

版本发布日期距今
3.0.1latest2026/04/306 个月前
3.0.02026/03/038 个月前
2.0.02026/03/028 个月前
1.1.12026/02/188 个月前
1.1.02026/02/139 个月前
1.1.0-next.1next2026/01/149 个月前

关于 @fiscozen/action 的常见问题

@fiscozen/action 是什么?

Design System Action component

如何安装 @fiscozen/action?

在项目目录运行 npm install @fiscozen/action,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:tailwindcss(^3.4.1)、vue(^3.4.13)、vue-router(^4.3.0)、@fiscozen/icons(^1.0.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fiscozen/action 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fiscozen__action 是否存在。

@fiscozen/action 支持 ESM 还是 CommonJS?

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

@fiscozen/action 可以商用吗?

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

@fiscozen/action 的下载量有多少?

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

@fiscozen/action 还在维护吗?

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