钱包
皮革钱包,里面装有卡片,您可以查看并取出。
- Dependencies (2)
功能
- 将鼠标悬停在一张卡片上查看它,后面的卡片也会随之升起。
- 单击或点击卡片将其拉出并显示其内容。
- 当钱包滚动进入视野时,卡片会从口袋中升起一次。
使用场景
- 定价页面上的英雄插图,每个计划一张卡。
- 在帐户页面上保存付款方式。
- 门票、通行证和会员资格集中在一处。
安装
pnpm dlx shadcn@latest add @yourname/wallet
用法
import {
Wallet,
WalletCard,
WalletCardContent,
WalletCardDescription,
WalletCardHeader,
WalletCards,
WalletCardTitle,
WalletLabel,
WalletPocket,
} from "@/components/wallet"<Wallet>
<WalletCards>
<WalletCard className="bg-sky-600 text-white">
<WalletCardHeader>
<WalletCardTitle>Travel</WalletCardTitle>
<WalletCardDescription>•••• 1945</WalletCardDescription>
</WalletCardHeader>
<WalletCardContent>
<p>$6,120.50</p>
</WalletCardContent>
</WalletCard>
</WalletCards>
<WalletPocket>
<WalletLabel>Wallet</WalletLabel>
</WalletPocket>
</Wallet>卡必须是 WalletCards 的直接子级。里面的所有东西都随着钱包的宽度而缩放。
成分
使用以下组合构建 Wallet
Wallet
├── WalletCards
│ └── WalletCard
│ ├── WalletCardHeader
│ │ ├── WalletCardTitle
│ │ └── WalletCardDescription
│ └── WalletCardContent
└── WalletPocket
└── WalletLabelAPI 参考
WalletCardTitle 渲染 h3。使用其 render 属性更改标题级别。 WalletCard 被拉出时具有 data-active。
示例
通行证
卡片可以采用任何颜色和内容,而钱包则可以容纳更多卡片。
无障碍
- 标题是带有
aria-expanded的按钮。 Escape将卡片放回原处并将焦点返回到其标题。- 封闭式卡片的内容不符合选项卡顺序,并且远离屏幕阅读器。
- 使用
prefers-reduced-motion,卡片会跳到适当的位置并且不会被偷看。
致谢
License and usage
- Free to use and modify in both personal and commercial projects.
- Attribution is appreciated but not required.
- Released under the MIT License.
Every component here is built and maintained by one person. If you enjoy using them, you can sponsor my work.