- Accordion
- Action Bar
- Action Toast
- Alert Banner
- Alert Dialog
- Alert
- Alphabet Index
- Amount Field
- Aspect Ratio
- Attachment
- Availability List
- Avatar
- Badge
- Bank Card
- Breadcrumb
- Bubble
- Button Group
- Button
- Calendar
- Camera Frame
- Card Design Picker
- Card Details
- Card Peek
- Card Stack
- Card
- Carousel
- Chart
- Chat Thread
- Checkbox
- Chip Group
- Choice Tile
- Code Block
- Code Dots
- Collapsible
- Combobox
- Command
- Context Menu
- Copy Field
- Countdown
- Country Select
- Data Table
- Date Field
- Date Picker
- Date Range Picker
- Dialog
- Direction
- Document Paper
- Drawer
- Dropdown Menu
- Empty
- Entity Avatar
- Field
- File Trigger
- File Upload Item
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Key Value
- Keypad
- Label
- Live Region
- Marker
- Message Scroller
- Message
- Money Amount
- Native Select
- Number Field
- Pagination
- Percent Split Editor
- Phone Field
- Popover
- Progress
- QR Code
- Questionnaire
- Radio Group
- Range Histogram
- Rating
- Resizable
- Scroll Area
- Search Field
- Select
- Separator
- Share Bar
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Sortable List
- Spinner
- Status Timeline
- Step Header
- Steps List
- Swipe Row
- Switch
- Table
- Tabs
- Text Field
- Textarea
- Tier Ladder
- Toggle Group
- Toggle
- Token Search Field
- Tooltip
- Trace
- Transaction Row
- Usage Meter
import { CardPeek } from "@/components/ui/card-peek"
/** A neutral issuer mark for the demo. Pass your own logo in a product. */The CardPeek component shows the top half of a payment card, as if it were sliding out of a pocket: the issuer mark, the network, a label and the last four digits. It stays dark in both themes. Use it to show which card a screen is about, under a balance or at the top of a card page, without a full card face. For a general content surface, use Card.
Installation#
pnpm dlx shadcn@latest add @dots/card-peek
Usage#
import { CardPeek } from "@/components/ui/card-peek"<CardPeek
last4="4242"
label="Virtual · USD"
mark={<IssuerLogo />}
network={<NetworkLogo />}
/>Features#
- A single component: no parts to compose
- Issuer mark and network logo slots; the card draws no logo of its own
- The last four digits with a full screen-reader phrase
- A frozen state that dims the face and says "Frozen" in words
- Static by default, or one link with
href, or one button withonPress - Dark in both themes
Frozen#
Set frozen to dim the face and show a "Frozen" badge. Change the badge text with frozenLabel.
"use client"
import * as React from "react"Pressable#
Pass onPress to make the whole peek one button, such as opening the card details sheet. Pass href instead to make it one link to the card page. Use one or the other, not both.
Press the card to see its details
"use client"
import * as React from "react"<CardPeek last4="0917" label="USD" mark={<IssuerLogo />} href="/cards/0917" />Before the card has a number#
Leave out last4 while the card is being ordered. The peek shows the label and logos without a number.
import { CardPeek } from "@/components/ui/card-peek"
/** A neutral issuer mark for the demo. Pass your own logo in a product. */Accessibility#
A static CardPeek is a <div>. With href it renders a React Aria Link, and with onPress a React Aria Button, so it works with a keyboard, a pointer and touch.
The number#
The masked number is hidden from assistive tech and replaced by a full phrase, "Card ending in 4242" by default. Use numberLabel to change the phrase, for example to translate it.
<CardPeek last4="4242" numberLabel={(digits) => `Card ending in ${digits}`} />Logos#
Pass decorative logos with aria-hidden="true". If the network matters, name it in label or in the peek's aria-label.
Pressable peeks#
When the peek is a link or a button, its name comes from its text. Pass aria-label when the action needs saying too, such as "Card ending in 0917, open details".
Frozen#
The frozen state is shown as the word "Frozen" with an icon, not by dimming alone.
API Reference#
CardPeek#
The card peek. Without href or onPress it accepts all <div> props. With href it accepts React Aria Link props, and with onPress React Aria Button props.
| Prop | Type | Default | Description |
|---|---|---|---|
last4 | string | - | Last four digits of the card number. Leave it out before the card has a number. |
numberLabel | (digits: string) => string | - | Screen-reader text for the number. Reads "Card ending in" and the digits by default. |
label | React.ReactNode | - | What the card is, shown above the number, e.g. "Virtual · USD". |
mark | React.ReactNode | - | Issuer mark, top start. |
network | React.ReactNode | - | Payment network logo, top end. |
frozen | boolean | false | Dims the face and shows the frozen badge. |
frozenLabel | string | "Frozen" | Text of the frozen badge. |
href | string | - | Makes the peek one link. Cannot be used with onPress. |
onPress | (e: PressEvent) => void | - | Makes the peek one button. Cannot be used with href. |
className | string | - | Additional classes to apply to the root. |