渐变按钮

返回组件库

渐变按钮

按钮

组件介绍

主题色渐变背景的按钮,悬停轻微上浮、按下回缩,传入 href 时渲染为链接,否则为普通按钮。

组件源码

astro
---
interface Props {
	/** 按钮文字 */
	label?: string;
	/** 跳转链接,设置后渲染为 <a>,否则为 <button> */
	href?: string;
}

const { label = "开始使用", href } = Astro.props;

const className =
	"inline-flex items-center gap-2 rounded-full bg-linear-to-r from-(--primary) to-(--primary)/60 px-5 py-2.5 text-sm font-semibold text-white shadow-lg transition-all duration-200 hover:-translate-y-0.5 hover:shadow-xl active:translate-y-0 active:scale-95 dark:text-black/75";
---

{
	href ? (
		<a href={href} class={className}>
			{label}
		</a>
	) : (
		<button type="button" class={className}>
			{label}
		</button>
	)
}
Profile Image of the Author
东方既白
大家好,我是东方既白
公告
欢迎来到我的博客!这是一则示例公告。
分类
标签
最新动态
站点统计
文章
14
分类
3
标签
22
总字数
20,428
运行时长
0 天
最后活动
0 天前
站点信息
构建平台
Cloudflare Workers
博客版本
Firefly v6.16.8
文章许可
CC BY-NC-SA 4.0

当前页面没有目录

文章目录

当前页面没有目录