UI Toolbox 徽标UI Toolbox
支持

本页为译文。技术支持和视频教程主要使用英语,内容以英文页面为准。 英文版

Card

Card 是带边框的容器:页眉包含标题、说明和右侧的操作,然后是内容,再是页脚。

Daily reward 卡片,带 Day 3 徽章、七个从 50 到 500 金币的日期方块(前两个已填充)、Today: 100 gold 一行和 Claim 按钮Daily reward 卡片,带 Day 3 徽章、七个从 50 到 500 金币的日期方块(前两个已填充)、Today: 100 gold 一行和 Claim 按钮

如何制作带页眉操作和页脚的卡片:

<tb:Card
    title="Plan"
    description="Your plan renews on the first day of each month.">
    <ui:Button text="Change" class="tb-card__action" />
    <ui:Label text="Pro, 5 seats" />
    <ui:Label text="12 GB of 50 GB used" />
    <ui:Button text="Cancel the plan" class="tb-card__footer" />
    <ui:Button text="Add seats" class="tb-card__footer" />
</tb:Card>
var card = new Card
{
    Title = "Plan",
    Description = "Your plan renews on the first day of each month."
};
card.Add(new Label("Pro, 5 seats"));
card.Action.Add(new Button(changePlan) { text = "Change" });
card.Footer.Add(new Button(addSeats) { text = "Add seats" });

标题是一个 AnimatedLabel,所以效果标签在其中有效。一个会闪光的金色渐变传奇标题:

quest.Title = "<gradient=#ff9f1c,#ffe066><shine>"
    + "The Hollow King</shine></gradient>";

这些颜色用于深色卡片,如默认的 toolbox 主题。在浅色卡片上请使用更深的颜色,使标题保持 4.5:1 的对比度。

成员 说明
Title (title) 页眉的粗体行。空标题不显示这一行。<wave> 这样的效果标签在其中有效;没有标签的标题每帧不做任何工作。
Description (description) 标题下方弱化的文本。富文本标签有效。空说明不显示这一行。
Icon (icon) 标题栏左侧的图片,在标题和描述的列上居中。它使用 --tb-color-text-muted 着色。没有图片时不显示,也不占空间。
Action 页眉右侧的位置。从代码中向其添加页眉按钮。
Footer 内容下方的一行。从代码中向其添加页脚按钮。

像设置页面一样的设置行:左侧图标、粗体标题、柔和的描述,右侧是分段选择器。选择器是放在操作插槽中的 ToggleButtonGroup:

<tb:Card
    icon="project://database/Assets/Icons/density.png"
    title="Density"
    description="How much room the lists take.">
    <ui:ToggleButtonGroup class="tb-card__action"
        allow-empty-selection="false">
        <ui:Button text="Comfortable" />
        <ui:Button text="Compact" />
    </ui:ToggleButtonGroup>
</tb:Card>

提示:

在示例中

样式

类 元素
tb-card 卡片:--tb-color-surface 背景、--tb-color-border 边框、--tb-radius-md 圆角和 --tb-spacing-md 内边距。
tb-card__header 包含文本和操作的行。没有内容时隐藏。
tb-card__icon 标题栏左侧的图片。大小为 --tb-size-button 的方块,颜色为 --tb-color-text-muted。没有图片时隐藏。
tb-card__headings 包含标题和说明的列。
tb-card__title 大字号的粗体标题,一个没有 tb-animated-label 类的 AnimatedLabel。
tb-card__description --tb-color-text-muted 的说明。
tb-card__action-slot 页眉右侧的行。
tb-card__content 内容子元素的父级。
tb-card__footer-slot 内容下方的行。
tb-card__action 放在子元素上,可将该子元素送入页眉。
tb-card__footer 放在子元素上,可将该子元素送入页脚。
.tb-card {
    padding: 16px;
    background-color: var(--tb-color-surface-alt);
}
.tb-card__footer-slot { justify-content: flex-end; }

CardDemo 场景展示了:使用默认值的每日奖励、用代码制作的商店物品卡片、带印章和目标的任务,以及角色卡片。