You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vaadin 23 如何创建无边缘透明按钮?

Vaadin 23 实现无边缘透明按钮的方案

Vaadin 23的LUMO主题没有直接提供无边缘透明按钮的内置样式,你可以通过以下两种方式实现:

方式一:基于内置tertiary样式扩展

tertiary样式本身已经移除了按钮的边框和默认背景,在此基础上调整透明度即可:

  1. 添加自定义CSS:
.vaadin-button.tertiary.transparent-btn {
    color: rgba(0, 0, 0, 0.6); /* 按需修改文本透明度,0为完全透明,1为不透明 */
    /* 若需要整体透明,可添加 opacity: 0.7; */
}
  1. 在Java代码中给按钮绑定样式类:
Button transparentButton = new Button("透明按钮");
transparentButton.addClassNames("tertiary", "transparent-btn");

方式二:完全自定义样式

如果需要更彻底的样式控制,直接编写自定义样式清除所有默认样式:

  1. 添加自定义CSS:
.transparent-edge-less-btn {
    background: transparent;
    border: none;
    box-shadow: none;
    color: inherit; /* 继承父元素文本颜色,可自行指定 */
    opacity: 0.7; /* 调整整体透明度 */
}
/* 可选:添加hover状态效果 */
.transparent-edge-less-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}
  1. 在Java代码中应用样式:
Button customBtn = new Button("无边缘透明按钮");
customBtn.addClassName("transparent-edge-less-btn");

内容的提问来源于stack exchange,提问作者Tullio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 04:52:02