提示条

对齐目标:@astryxdesign/core v0.7.1 · Banner

A new software update is available.
Your changes have been saved.
Your trial expires in 3 days.
Upgrade to keep access to all features.
Payment failed.
Update your billing information to continue.

使用方法 #

Banner 用于持续展示需要用户关注或处理的消息,例如功能更新、操作结果或需要解决的问题。与会自动消失的 Toast 不同,它会一直留在界面上,直到用户处理或主动关闭:

Vue
<script setup lang="ts">
import { Banner } from '@astryx-vue/core/Banner'
</script>

<template>
  <Banner
    status="success"
    title="Changes saved"
    description="Your settings are up to date."
    is-dismissable
  />
</template>

主题在应用入口引入一次:

TypeScript
import '@astryx-vue/themes/neutral.css'

解剖

部分说明
通告框把状态面和可选的内容面包在一起的外框。整条通告的抬升由它承担;抬升的卡片样式还会带上形成轮廓的圆角。
状态面主要着色的那一面。它表达状态,并装着图标、标题、说明、操作和控件。
图标按状态自动选择:信息、警告、错误、成功。
标题主要信息。必填。
说明标题下面的补充。
操作按钮让用户针对这条信息做事的按钮,比如「查看」或「重试」。
关闭按钮让用户关掉通告。设置 isDismissable 后出现。
内容面状态面下面的第二层,放额外细节,比如一列错误。默认藏在展开和收起开关后面;把 collapsible 设为 false 就一直显示。

最佳实践 #

指引实践
推荐选择与消息相符的状态:更新用 info,注意事项用 warning,问题用 error,确认用 success。
推荐页面内容中使用 card 容器。覆盖整页宽度的消息使用 section 容器。
推荐info 和 success 提示条可以关闭。error 提示条必须保留,直到用户解决问题。
推荐标题保持简短、便于扫读。例如用 “Payment failed”,不用 “There was a problem processing your most recent payment.”
避免用提示条展示会自动消失的短暂消息。应改用 Toast。
避免叠放同一状态的多条提示条。应把相关消息合并为一条。

示例 #

提示条 — 可折叠

Configuration changes detected
Review the changes before they take effect.
Changed settings:

同一条提示里放操作按钮、关闭按钮,以及默认展开的详情。详情写在默认插槽里。

提示条 — 关闭

Deployment complete
Version 3.2.0 is now live in production.
Scheduled maintenance tonight
The system will be briefly unavailable from 2:00–3:00 AM.
New feature available
Try the new dashboard layout in Settings.

isDismissable 让用户读完后关掉提示。适合维护通知和功能介绍。

提示条 — 浮动

You have unsaved changes
A raised banner reads as an overlay floating above the page.

elevation 设为 med 后,提示条浮在页面之上,读起来像一层悬空通知。

提示条 — 通栏

Scheduled downtime
All services will be unavailable on Sunday from 2:00–4:00 AM.
Welcome to the new dashboard
We have redesigned the layout based on your feedback.

container 设为 section 后,提示条铺满整行,没有圆角,适合放在页面顶部。

提示条 — 状态

A new software update is available
Version 2.4.1 includes performance improvements and bug fixes.
Changes saved
Your profile information has been updated successfully.
Storage almost full
You have used 90% of your available storage.
Build failed
3 tests did not pass. Check the logs for details.

info、success、warning、error 四种状态,分别用于更新、完成、提醒和出错。

提示条 — 操作

Your trial expires in 3 days
Upgrade now to keep access to all features.
API key expires soon
Generate a new key before December 1 to avoid service interruption.
Payment failed
We could not process your last payment.

end 插槽放一个按钮,让用户能直接处理这条消息。

使用建议 #

提示条的语气由 status 决定,选错状态会让用户误判消息的紧迫程度。下面按消息的性质说明该选哪个状态,以及两个容易忽略的用法。

  • 一般的信息和更新使用 info。
  • 操作成功的结果使用 success。
  • 需要提醒用户注意的情况使用 warning。
  • 阻止用户继续操作的问题使用 error。
  • 用户必须读到的详情传入 :collapsible="false",这样详情会始终显示,不需要再点开。详情很长、会把提示本身盖住时,保持默认可折叠。
  • 用户操作之后才出现的结果,在这次操作的处理函数里用 useAnnounce 播报。

status 只决定颜色和图标,不会自己变成实时区域。需要一直被读屏当成状态时,显式写上 role="status"。只有真正紧急、必须打断当前朗读的内容才写 role="alert"。页面初次渲染时就已经在的内容,读屏不一定会再念一遍。

如果只是单个字段的校验消息,应改用 FieldStatus。