Check Mark
ericts-ui/check-markFreeComponent
A pure SVG checkmark animation that draws a square or circle before the check.
Live preview
live · rendered by the registry
Rendered by ericts-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.ericts.com/r/check-mark.jsonSource
1import * as React from "react";23import { cn } from "@/lib/utils";45import "./check-mark.css";67export type CheckMarkVariant = "square" | "circle";8export type CheckMarkSize = "sm" | "md" | "lg";910export interface CheckMarkProps11 extends Omit<React.ComponentProps<"span">, "children"> {12 variant?: CheckMarkVariant;13 size?: CheckMarkSize;14 /** Accessible label. Omit for a decorative mark. */15 label?: string;16 strokeWidth?: number;17}1819const sizeClassNames: Record<CheckMarkSize, string> = {20 sm: "size-5",21 md: "size-6",22 lg: "size-10",23};2425const DEFAULT_STROKE_WIDTH = 2;26const VECTOR_EFFECT = "non-scaling-stroke";27const SQUARE_PATH = "M 50,11.5 L 88.5,11.5 L 88.5,88.5 L 11.5,88.5 L 11.5,11.5 Z";28const CIRCLE_PATH =29 "M 88.5,50 C 88.5,71.26 71.26,88.5 50,88.5 C 28.74,88.5 11.5,71.26 11.5,50 C 11.5,28.74 28.74,11.5 50,11.5 C 71.26,11.5 88.5,28.74 88.5,50 Z";30const CHECK_PATH = "M 32.3,51 L 44,62.9 L 68.75,36.5";3132const shapePaths: Record<CheckMarkVariant, string> = {33 square: SQUARE_PATH,34 circle: CIRCLE_PATH,35};3637export function CheckMark({38 variant = "square",39 size,40 label,41 strokeWidth = DEFAULT_STROKE_WIDTH,42 "aria-label": ariaLabel,43 "aria-hidden": ariaHidden,44 className,45 ...props46}: CheckMarkProps) {47 const accessibleLabel = label ?? ariaLabel;4849 return (50 <span51 data-slot="check-mark"52 data-variant={variant}53 role={accessibleLabel ? "img" : undefined}54 aria-label={accessibleLabel}55 aria-hidden={accessibleLabel ? undefined : (ariaHidden ?? true)}56 className={cn(57 "check-mark inline-flex shrink-0 items-center justify-center text-foreground",58 size ? sizeClassNames[size] : "w-full max-w-80",59 className,60 )}61 {...props}62 >63 <svg64 viewBox="0 0 100 100"65 aria-hidden="true"66 className={size ? "size-full" : "h-auto w-full"}67 >68 <path69 className="check-mark-shape"70 d={shapePaths[variant]}71 fill="none"72 stroke="currentColor"73 strokeWidth={strokeWidth}74 strokeLinecap="round"75 strokeLinejoin="round"76 vectorEffect={VECTOR_EFFECT}77 pathLength="100"78 strokeDasharray="100 100"79 strokeDashoffset="100"80 />81 <path82 className="check-mark-checkmark"83 d={CHECK_PATH}84 fill="none"85 stroke="currentColor"86 strokeWidth={strokeWidth}87 strokeLinecap="round"88 strokeLinejoin="round"89// … truncated
Files it writes
More from ericts-ui
All 43 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Adaptive Draweradaptive-drawer | ericts-ui | Components | Free | 2 deps | |
| Adaptive Switchadaptive-switch | ericts-ui | Components | Free | 2 deps | |
| Context Cursorcontext-cursor | ericts-ui | Components | Free | 1 dep | |
| Copy Buttoncopy-button | ericts-ui | Components | Free | 2 deps | |
| Expandable Dialogexpandable-dialog | ericts-ui | Components | Free | 1 dep | |
| Expandable Panelexpandable-panel | ericts-ui | Components | Free | 2 deps | |
| Expandable Segmented Tabsexpandable-segmented-tabs | ericts-ui | Components | Free | 1 dep | |
| Expandable Sliderexpandable-slider | ericts-ui | Components | Free | no deps |
