Skip to main content

Module ui

Module ui 

Source
Expand description

通用 UI 原子与全部 class 常量(卡片 / 按钮 / 徽章 / 分页 / spinner / checkbox)。 任何 inline Tailwind class 字符串上线前,先在此查是否已有常量。 通用 UI 原子组件与类名常量。

提供跨页面共享的样式常量(卡片、按钮、徽章外层等)与可复用组件 (分页导航、状态徽章、空状态)。样式常量用于消除散落在各页面的重复 Tailwind 类字符串;组件用于封装结构固定的 UI 单元。

与 forms.rs(表单控件)并列,本模块聚焦通用展示类原子。

Modules§

composer 🔒
输入栏:圆角外壳 + 输入框 + 陶土发送键。
controls 🔒
Buttons and native selection controls.
display 🔒
Badges, avatars, placeholders and CSS tooltips.
feedback 🔒
全站提示(Toast):操作结果的短暂反馈,出现在屏幕底部居中;区块加载失败卡片。
icons 🔒
Lucide 图标(ISC 许可,见 public/icons/LICENSE-lucide.txt)。
menu 🔒
操作菜单:「⋯」等按钮触发的一列操作。
navigation 🔒
Pagination, tabs and navigable tag chips.
segmented 🔒
分段控件:胶囊轨道 + 弹簧滑块。
sheet 🔒
抽屉:手机上的导航与目录面板。底部抽屉样式见 shell.css 的 .sheet, 左侧抽屉(后台导航)见 admin.css 的 .side-sheet。
styles 🔒
共享样式常量与 spinner 标记。
surfaces 🔒
Positioned popovers, modal shells and the danger confirm dialog.

Structs§

BottomSheetProps
Props for the BottomSheet component.
BreadcrumbProps
Props for the Breadcrumb component.
ButtonProps
Props for the Button component.
CheckboxProps
Props for the Checkbox component.
ComposerInputProps
Props for the ComposerInput component.
ComposerProps
Props for the Composer component.
ComposerSendProps
Props for the ComposerSend component.
ConfirmDialogProps
Props for the ConfirmDialog component.
Crumb
面包屑中的一级。最后一级是当前页(不可点击,标 aria-current);中间级 to 为 None 时是不可点击的分组名(如后台的「内容」)。
IconButtonProps
Props for the IconButton component.
IconProps
Props for the Icon component.
ImagePlaceholderProps
Props for the ImagePlaceholder component.
LoadErrorProps
Props for the LoadError component.
MenuItem
菜单里的一项。id 回传给 on_select,用于区分点了哪一项。
MenuProps
Props for the Menu component.
ModalShellProps
Props for the ModalShell component.
PaginationProps
Props for the Pagination component.
PopoverProps
Props for the Popover component.
RadioProps
Props for the Radio component.
SegmentedControlProps
Props for the SegmentedControl component.
SegmentedItem
分段控件的一项:值、文字,可选图标与数量。
SheetClose
抽屉内容用来关闭抽屉(带退出动画、焦点还给触发按钮)。
SideSheetProps
Props for the SideSheet component.
StatusBadgeProps
Props for the StatusBadge component.
StatusDotProps
Props for the StatusDot component.
TablePagerProps
Props for the TablePager component.
TagChipProps
Props for the TagChip component.
ToastRegionProps
Props for the ToastRegion component.
Toaster
发提示的句柄,经 use_toast 取得。
TooltipProps
Props for the Tooltip component.
UserAvatarProps
Props for the UserAvatar component.

Enums§

ButtonSize
按钮尺寸:XS 26px、SM 30px、MD 34px、LG 40px。
ButtonVariant
按钮样式,对应 styles/components/ui.css 的 .btn-*。
ComposerSize
IconName
Lucide 图标名。渲染见 super::Icon。
SegmentedKind
语义:Tabs = tablist/tab + aria-selected(切换视图、筛选); Radio = radiogroup/radio + aria-checked(设置取值)。
SegmentedSize
ToastTone
提示的语气。

Constants§

BADGE_BASE
徽章底座(.badge,中性色);语气追加 badge-clay / badge-success / badge-warning / badge-danger。
BTN_SECONDARY
次要按钮:浅灰底。
EXIT_ANIM_MS
弹窗关闭/元素退出动画统一时长(ms),与 base.css 的 .modal-overlay / .modal-panel 关闭过渡对应; 调用方需要在动画播放完毕后再真正卸载/摘除元素时复用本常量。
SPINNER_SVG
行内加载 spinner:环形渐变 + 自旋动画,用 currentColor 继承文字色。

Functions§

BottomSheet
底部抽屉。
Breadcrumb
面包屑:关于 / 组件图鉴 / 复选框,最后一级为当前页并在过长时截断。
Button
通用按钮。
Checkbox
带勾画动画的复选框:对勾 SVG 用 stroke-dashoffset 描边绘制 + scale 弹入。
Composer
输入栏外壳:20px(Sm 为 14px)圆角、surface-3、发丝线 + composer 阴影, 聚焦时 Clay 双环。
ComposerInput
输入栏里的输入框:单行 input 或多行 textarea(field-sizing: content), 自带输入法守卫。
ComposerSend
陶土发送键。不给 onclick 时为 type=submit。
ConfirmDialog
危险操作确认对话框(alertdialog):左侧 danger 图标、标题与说明,底栏「取消」与 danger 主按钮。点确认先关闭再回调 on_confirm,执行与结果提示由调用方负责。 title 同时作为面板的无障碍名称,同一时刻打开的对话框标题不能重复。
Icon
内联 SVG 图标。
IconButton
只有图标的方形按钮。label 必填:作为读屏名称,同时显示为悬浮提示; shortcut 会跟在提示文字后面。
ImagePlaceholder
封面与头像加载失败时的图片占位:Lucide image-off 图标,尺寸与颜色由 class 控制。
LoadError
区块加载失败卡片:页面其余部分照常显示,只有出错的区块换成它;重试在原位完成。
Menu
图标按钮触发的操作菜单。
ModalShell
通用弹窗外壳:遮罩 + 面板容器 + 开合动画状态机(opened / closing / 退出计时)。
Pagination
前台列表分页:上一页 / 下一页描边按钮与居中的「当前 / 总」页码,首尾页不渲染越界按钮。
Popover
受控式通用 Popover(浮层)组件。
Radio
主题化单选框,与 Checkbox 使用相同尺寸、主题色和焦点描边。
SegmentedControl
分段控件。
SideSheet
左侧抽屉。
StatusBadge
状态徽章组件。
StatusDot
状态圆点:6px 圆点 + 文字(.status-dot),后台列表与面板的状态标识。
TablePager
表格底栏分页:左侧「第 21–40 篇,共 57 篇」,右侧上一页、页码与下一页图标按钮。 只有一页时只显示总数。
TagChip
标签芯片组件:统一软底标签、卡片胶囊与文字链接的展示。
ToastRegion
提示显示区:固定在屏幕底部居中,aria-live 让读屏软件播报新提示。
Tooltip
悬浮提示:深色小气泡,悬停 300ms 后出现,键盘聚焦触发器时立即出现。
UserAvatar
用户头像:加载失败显示图片占位,无图回退展示名首字符(陶土浅底)。
button_class
组合按钮类名,供 <a>、label 等需要按钮外观的非按钮元素使用。
provide_toaster
在应用根部提供提示上下文(App 调用一次)。
use_sheet_close
在 BottomSheet / SideSheet 的子组件里取得关闭句柄。
use_toast
取得发提示的句柄。