示例
图标按钮上的工具提示
工具提示为 icon-sm 按钮提供仅凭图标无法表达的标签。
预览
Production API key
sk_live_...9frA
Keys are shown once and stored hashed. Rotate them from Settings.
HTML
<bs:bsui-stack direction="row" gap="2" align="center">
<bs:bsui-text content="Production API key" variant="label" tag="span" />
<bs:bsui-text content="sk_live_...9frA" variant="code" tag="span" />
<bs:bsui-tooltip openDelay="0">
<bs:bsui-tooltip-trigger trigger_label="?" trigger_variant="ghost" trigger_size="icon-sm" />
<bs:bsui-tooltip-popup content="Keys are shown once and stored hashed. Rotate them from Settings." />
</bs:bsui-tooltip>
</bs:bsui-stack>工作原理
工具提示状态存储通过触发按钮上的指令,在悬停或聚焦时打开提示,因此键盘用户和指针用户都能看到相同提示。上下文会将弹出层与触发器关联,以便辅助技术识别;失焦、按下 Escape,或关闭延迟后指针离开,都会关闭提示。
此页面上的每项行为都是 WordPress Interactivity API:每个组件都会注册自己的 store,在服务器渲染的上下文中初始化状态,并通过上方标记中的指令绑定事件。没有针对单个页面的 JavaScript。