1280px
설치
이 명령 한 줄이면 필요한 파일과 패키지가 함께 설치돼요.
터미널터미널터미널bash
npx shadcn@latest add https://dsui.vercel.app/r/chip.json파일
components/arc/chip/chip.module.csscomponents/arc/chip/chip.tsx
npm 패키지
@hugeicons/core-free-icons@^4.3.5@hugeicons/react@^1.1.10
함께 오는 항목
- v1.1.0태그 아이콘(icon)을 더하고 모양을 다듬었어요.
- v1.0.0처음 공개했어요.
chip.module.csschip.module.csschip.module.csscss
.list { display: flex; flex-wrap: wrap; margin: 0; padding: 0; gap: var(--space-2); list-style: none; }
/* A soft pill: a quiet fill and no visible rim, so a row of tags reads as one calm group instead of a row of outlined boxes. The fill is
a variable, so a chip on a surface-muted block can switch to --surface. The edge stays 1px (transparent) so a chip never changes size. */
.chip { position: relative; isolation: isolate; display: inline-flex; min-height: var(--control-height-sm); align-items: center; gap: var(--space-1); border: 1px solid transparent; border-radius: var(--radius-pill); padding: 0 14px; background: var(--chip-bg, var(--surface-muted)); color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500; line-height: 20px; text-decoration: none; white-space: nowrap; }
.sm { min-height: 26px; padding: 0 10px; font-size: var(--text-xs); }
/* The icon sits a full space-2 from the label (the count keeps the tighter gap), a little quieter than the word, and warms with it on hover. */
.icon { display: inline-flex; flex: none; margin-inline-end: var(--space-1); color: var(--text-muted); transition: color var(--duration-fast) var(--ease-standard); }
.chip:has(.icon) { padding-inline-start: 10px; }
.sm:has(.icon) { padding-inline-start: 8px; }
/* The number is context, not the label, so it stays a step quieter than the word it follows. */
.count { color: var(--text-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.link { -webkit-tap-highlight-color: transparent; transition: color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard); }
@media (hover: hover) and (pointer: fine) {
.link:hover { background: var(--accent-subtle); color: var(--accent-strong); }
.link:hover .icon { color: var(--accent); }
}
.link:active { background: var(--accent-subtle); color: var(--accent-strong); transform: scale(.97); }
/* The current filter is told apart by a filled face and a stronger edge, not by color alone. */
.link[aria-current="true"] { background: var(--accent); color: var(--accent-foreground); }
.link[aria-current="true"] .count, .link[aria-current="true"] .icon { color: var(--accent-foreground-muted); }
@media (hover: hover) and (pointer: fine) {
.link[aria-current="true"]:hover { background: var(--accent); color: var(--accent-foreground); }
.link[aria-current="true"]:hover .icon { color: var(--accent-foreground-muted); }
}
@media (prefers-reduced-motion: reduce) { .link, .icon { transition: none; } .link:active { transform: none; } }
chip.tsxchip.tsxchip.tsxtsx
"use client";
import { Tag01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import type { HTMLAttributes, ReactNode } from "react";
import { ArcLink } from "../lib/arc-provider";
import { playUiSound } from "../sound/play";
import { DecorParticles, useDecorEdgeClass } from "../decor";
import styles from "./chip.module.css";
export type ChipSize = "sm" | "md";
export interface ChipProps {
/** Makes the chip a link. Without it the chip is a plain label. */
href?: string;
/** Marks the filter the reader is on. Only meaningful with `href`. */
current?: boolean;
size?: ChipSize;
/** A small mark before the label, such as the tag icon. It keeps a gap from the label and takes the label's colour. Hidden from assistive tech. */
icon?: ReactNode;
/** A quiet number after the label, such as how many items a tag holds. */
count?: number | string;
/** The language of the label, when it differs from the page. */
lang?: string;
className?: string;
children: ReactNode;
}
/**
* A pill for a tag or a filter. With `href` it goes somewhere; without one it is a label and gets no hover or press,
* because nothing happens when you touch it. For chips that are *chosen* rather than followed — a filter that changes
* the list in place — use ChipGroup, which keeps selection and arrow-key movement.
*/
/** The mark for a tag chip: `<Chip icon={<TagIcon />}>`. It replaces a typed "#", which reads as part of the word. */
export function TagIcon({ size = 14 }: { size?: number }) {
return <HugeiconsIcon icon={Tag01Icon} size={size} strokeWidth={1.75} aria-hidden="true" />;
}
export function Chip({ href, current = false, size = "md", icon, count, lang, className, children }: ChipProps) {
const edgeClass = useDecorEdgeClass();
const classes = [styles.chip, styles[size], edgeClass, className].filter(Boolean).join(" ");
const content = (
<>
<DecorParticles slot="chip" />
{icon ? <span className={styles.icon} aria-hidden="true">{icon}</span> : null}
{children}
{count === undefined ? null : <span className={styles.count}>{count}</span>}
</>
);
if (!href) {
return <span className={classes} lang={lang} data-arc-chip="label">{content}</span>;
}
return (
<ArcLink
href={href}
lang={lang}
// A stable hook for surroundings that restyle chips (a coloured StoryBand drops the rim); CSS-module class names are hashed.
data-arc-chip="link"
className={[classes, styles.link].join(" ")}
aria-current={current ? "true" : undefined}
onClick={() => playUiSound("tick")}
>
{content}
</ArcLink>
);
}
export interface ChipListProps extends HTMLAttributes<HTMLUListElement> {
/** The accessible name of the row, e.g. "태그". */
label?: string;
children: ReactNode;
}
/** A wrapping row of chips as a real list, so a screen reader announces how many there are. Wrap each Chip in an `<li>`. */
export function ChipList({ className, label, children, ...props }: ChipListProps) {
return (
<ul {...props} aria-label={label} className={[styles.list, className].filter(Boolean).join(" ")}>
{children}
</ul>
);
}
Chip.displayName = "Chip";
ChipList.displayName = "ChipList";
export default Chip;
이 항목을 쓰는 조합
- 글 머리블록
글의 첫 띠예요. 돌아가기 링크, 태그 알약, 아주 굵은 제목, 요약, 날짜, 번역과 마크다운 링크를 한 띠에 모으고, 옆에 일러스트나 소리 없는 반복 영상을 둘 수 있어요.