1280px
설치
이 명령 한 줄이면 필요한 파일과 패키지가 함께 설치돼요.
터미널터미널터미널bash
npx shadcn@latest add https://dsui.vercel.app/r/link-card.json파일
components/arc/link-card/link-card.module.csscomponents/arc/link-card/link-card.tsx
함께 오는 항목
- v1.0.0처음 공개했어요.
link-card.module.csslink-card.module.csslink-card.module.csscss
/* A card that sits on the page, so hover lifts it a little; it is not a floating layer and keeps a real border. The text carries its own `text-decoration: none`: a page's link underline (a prose `a` rule) paints through every child of the link, so setting it on the card alone leaves the title and description underlined. */
.card { position: relative; isolation: isolate; display: flex; align-items: center; gap: var(--space-4); box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius-surface); padding: var(--space-5); background: var(--surface); color: var(--foreground); text-decoration: none; -webkit-tap-highlight-color: transparent; transition: border-color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard), transform var(--duration-spring) var(--ease-spring); }
/* A page's own link rules (a post body's `.prose-blog a`, a designed band's prose links: underline, a small radius, bold, a colour and opacity transition, a dim on press) are more specific than `.card`, so they won
cut the card's lift and underlined its text. Doubling the class out-ranks them; the card sets these itself. */
.card.card { border-radius: var(--radius-surface); font-weight: 400; text-decoration: none; transition: border-color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard), transform var(--duration-spring) var(--ease-spring); }
.card.card, .card.card:hover, .card.card:active { color: var(--foreground); opacity: 1; }
.card, .card * { text-decoration: none; }
.body { display: flex; min-width: 0; flex: 1 1 auto; flex-direction: column; gap: var(--space-1); }
.eyebrow { align-self: flex-start; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px var(--space-3); background: var(--surface-sunken); color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--label-weight); line-height: 1.5; }
.title { color: var(--foreground); font-size: var(--text-lg); font-weight: 600; line-height: 1.4; text-wrap: balance; word-break: keep-all; }
.description { display: -webkit-box; overflow: hidden; color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.6; word-break: keep-all; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.meta { color: var(--text-secondary); font-size: var(--text-xs); overflow-wrap: anywhere; }
.icon { display: inline-flex; width: 3.5rem; height: 3.5rem; flex: none; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--foreground); }
/* The go button: a pill that fills with the accent when the card is pointed at or pressed. Its shadow follows the accent fill. */
.go { display: inline-flex; width: 2.75rem; height: 2.75rem; flex: none; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); color: var(--foreground); transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
/* The arrow points up and right: the link leaves the page. */
.arrow { transform: rotate(-45deg); }
.card[aria-current="page"] { border-color: transparent; background: var(--accent-subtle); }
@media (hover: hover) and (pointer: fine) {
.card:hover { border-color: var(--border); box-shadow: var(--shadow-raised); transform: translateY(-4px); }
.card:hover .go { border-color: var(--accent); background: var(--accent); color: var(--accent-foreground); box-shadow: var(--shadow-accent-resting); }
.card[aria-current="page"]:hover { border-color: var(--accent); }
}
.card:active { box-shadow: var(--shadow-resting); transform: translateY(0) scale(.97); }
.card:active .go { border-color: var(--accent); background: var(--accent); color: var(--accent-foreground); }
@media (max-width: 30rem) { .card { gap: var(--space-3); padding: var(--space-4); } .icon { width: 3rem; height: 3rem; } .go { width: 2.5rem; height: 2.5rem; } }
@media (prefers-reduced-motion: reduce) {
.card.card, .go { transition: none; }
.card:hover, .card:active { transform: none; }
}
link-card.tsxlink-card.tsxlink-card.tsxtsx
"use client";
import type { ReactNode } from "react";
import { ArcLink } from "../lib/arc-provider";
import { playUiSound } from "../sound/play";
import { UiIcon } from "../theme/ui-icon";
import { DecorParticles, useDecorEdgeClass } from "../decor";
import styles from "./link-card.module.css";
export interface LinkCardProps {
href: string;
/** The card's heading, and the link's accessible name. */
title: ReactNode;
/** One or two lines under the title. */
description?: ReactNode;
/** A short word above the title, such as "다음 단계". */
eyebrow?: ReactNode;
/** A mark at the start of the card, e.g. an icon in a tinted square. */
icon?: ReactNode;
/** A small line under the description, such as the address the link goes to. */
meta?: ReactNode;
/** The arrow at the end. On by default; turn it off for a card that is not a "go there" card. */
arrow?: boolean;
/** Marks the card as the page the reader is on. */
current?: boolean;
className?: string;
/** Anything after the description, such as a row of chips. Keep it free of links and buttons. */
children?: ReactNode;
}
/**
* A card whose whole face is one link. Nothing inside it may be a link or a button of its own: two targets inside one
* target leave the reader guessing which one they hit, and a screen reader reads them as separate stops. For a card
* that carries its own actions, use Card and put a link in it instead.
*/
export function LinkCard({
href,
title,
description,
eyebrow,
icon,
meta,
arrow = true,
current = false,
className,
children,
}: LinkCardProps) {
const edgeClass = useDecorEdgeClass();
return (
<ArcLink
href={href}
className={[styles.card, edgeClass, className].filter(Boolean).join(" ")}
aria-current={current ? "page" : undefined}
onClick={() => playUiSound("tick")}
>
<DecorParticles slot="card" />
{icon ? <span className={styles.icon} aria-hidden="true">{icon}</span> : null}
<span className={styles.body}>
{eyebrow ? <span className={styles.eyebrow}>{eyebrow}</span> : null}
<span className={styles.title}>{title}</span>
{description ? <span className={styles.description}>{description}</span> : null}
{meta ? <span className={styles.meta}>{meta}</span> : null}
{children}
</span>
{arrow ? (
<span className={styles.go} aria-hidden="true">
<UiIcon iconRole="arrow-right" size={20} strokeWidth={1.75} className={styles.arrow} />
</span>
) : null}
</ArcLink>
);
}
LinkCard.displayName = "LinkCard";
export default LinkCard;