拟态卡片
点击试试 hover 效果
♡
状态:未收藏
点击数 · 0
card · neumorphic · 灵感来源:Neumorphism(同色浮起 + 一组双阴影)
点击试试 hover 效果
状态:未收藏
点击数 · 0
Neumorphic Card · 拟态卡片 · 卡片 / Neumorphic
做一个 Neumorphic Card(拟态卡片):
- 同色底 + 一组外双阴影浮起,没有边框与模糊
- hover 只提亮表面到 --neuro-light,不再抬高
- 可点时 role=button,Enter / 空格触发
- 标题/副标/内容 slot 与玻璃卡片一致
用这些 CSS 变量:--color-accent --color-text-muted --dur-fast --fw-semibold --neuro-bg --neuro-light --neuro-shadow
灵感参考:Neumorphism(同色浮起 + 一组双阴影)--color-accent --color-text-muted --dur-fast --fw-semibold --neuro-bg --neuro-light --neuro-shadow
(无必缺状态)
(尚未接进整页场景)
/r/card--neumorphic.json
免外壳的 markdown 版:/llms/components/card--neumorphic.md--neuro-shadow 向外出,没有边框、模糊与内高光--neuro-light,避免阴影叠加出第二套深度role=button、Enter / 空格触发与焦点环限制:卡片与页面同色,边界完全靠阴影;背景有渐变或强纹理时分层会失效。
import { type ReactNode } from 'react';
interface Props {
title?: string;
subtitle?: string;
children?: ReactNode;
onClick?: () => void;
className?: string;
}
/**
* 拟态卡片:与玻璃、极简卡片同一份 props,
* 同色浮起(一组外双阴影),没有边框与模糊;hover 只提亮表面,不再抬高。
*/
export function NeumorphicCard({
title,
subtitle,
children,
onClick,
className = '',
}: Props) {
const hasHeader = title || subtitle;
return (
<article
onClick={onClick}
role={onClick ? 'button' : undefined}
tabIndex={onClick ? 0 : undefined}
onKeyDown={onClick ? (event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
onClick();
}
} : undefined}
className={`
relative
rounded-2xl
bg-[var(--neuro-bg)]
shadow-[var(--neuro-shadow)]
transition-[background-color] duration-[var(--dur-fast)]
${onClick ? 'hover:bg-[var(--neuro-light)] cursor-pointer' : ''}
p-6
${className}
`}
>
{hasHeader && (
<div className="mb-4">
{title && (
<h3
className="text-base"
style={{ fontWeight: 'var(--fw-semibold)' }}
>
{title}
</h3>
)}
{subtitle && (
<p className="text-sm text-[var(--color-text-muted)] mt-1">{subtitle}</p>
)}
</div>
)}
{children}
</article>
);
}
src/components/card/neumorphic/