OpenSourceUIOpenSourceUIOpensource UI
GitHub—
  1. Home
  2. Components
  3. Frames
  4. Circle Cut Frame
Back to FramesComponents / Frames

Circle Cut Frame

Free Frames React component — CircleCutFrame. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

Ticket-style frame with circle-cut edges on all sides — defaults to white; pass width, height, frameColor, and any image, video, or content as children.

Preview

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/frames/circle-cut-frame.tsx in your project.

  4. 4

    Import and render:

    Example

    import { CircleCutFrame } from "@/components/frames/circle-cut-frame";

    <CircleCutFrame width={320} height={320} frameColor="#d4d4d4"><img src="/photo.jpg" alt="" /></CircleCutFrame>

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/frames/circle-cut-frame.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import {
forwardRef,
type ComponentPropsWithoutRef,
type CSSProperties,
type ReactNode,
} from "react";
 
import { cn } from "@/lib/cn";
 
const MEDIA_SLOT =
"[&_img]:block [&_img]:size-full [&_img]:object-cover [&_video]:block [&_video]:size-full [&_video]:object-cover [&_iframe]:block [&_iframe]:size-full [&_iframe]:border-0";
 
const FRAME_COLOR = "#ffffff";
 
function toCssSize(value: string | number) {
return typeof value === "number" ? `${value}px` : value;
}
 
function edgeCutStyle(
edge: "top" | "bottom" | "left" | "right",
color: string,
): CSSProperties {
if (edge === "top") {
return {
background: `radial-gradient(circle at 8px 0, transparent 6px, ${color} 6px)`,
backgroundSize: "16px 8px",
};
}
 
if (edge === "bottom") {
return {
background: `radial-gradient(circle at 8px 8px, transparent 6px, ${color} 6px)`,
backgroundSize: "16px 8px",
};
}
 
if (edge === "left") {
return {
background: `radial-gradient(circle at 0 8px, transparent 6px, ${color} 6px)`,
backgroundSize: "8px 16px",
};
}
 
return {
background: `radial-gradient(circle at 8px 8px, transparent 6px, ${color} 6px)`,
backgroundSize: "8px 16px",
};
}
 
function MediaSkeleton() {
return (
<div className="absolute inset-0 overflow-hidden bg-neutral-50">
<div className="absolute inset-0 bg-neutral-100/50 motion-safe:animate-pulse" />
 
<div className="absolute inset-0 flex items-center justify-center">
<svg
viewBox="0 0 48 48"
aria-hidden
className="size-14 text-neutral-200"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
>
<rect x="4" y="8" width="40" height="32" rx="2" />
<circle cx="16" cy="18" r="3" fill="currentColor" stroke="none" />
<path
d="M8 34l10-9 7 6 6-5 9 8"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</div>
</div>
);
}
 
function MediaPlaceholder() {
return (
<div className="flex size-full items-center justify-center bg-neutral-100">
<svg
viewBox="0 0 20 20"
aria-hidden
className="size-5 text-neutral-300"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
>
<rect x="2.5" y="4" width="15" height="12" rx="1.5" />
<circle cx="7" cy="8.5" r="1.25" fill="currentColor" stroke="none" />
<path
d="M5.5 14l3.5-3 2.5 2 2-1.5 3 2.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</div>
);
}
 
export type CircleCutFrameProps = Readonly<
{
children?: ReactNode;
width?: string | number;
height?: string | number;
mediaClassName?: string;
skeleton?: boolean;
frameColor?: string;
} & ComponentPropsWithoutRef<"div">
>;
 
export const CircleCutFrame = forwardRef<HTMLDivElement, CircleCutFrameProps>(
(
{
className,
children,
width,
height,
mediaClassName,
skeleton = false,
frameColor = FRAME_COLOR,
style,
...props
},
ref,
) => {
const hasFixedWidth = width !== undefined;
const hasFixedHeight = height !== undefined;
const hasFixedSize = hasFixedWidth && hasFixedHeight;
 
const frameStyle: CSSProperties = {
...(hasFixedWidth ? { width: toCssSize(width) } : undefined),
...(hasFixedHeight ? { height: toCssSize(height) } : undefined),
...style,
};
 
return (
<div
ref={ref}
data-slot="circle-cut-frame"
className={cn(
"font-sans",
!hasFixedWidth && "w-64 max-w-full",
className,
)}
style={frameStyle}
{...props}
>
<div
className={cn(
"relative flex flex-col p-4 shadow-md",
hasFixedHeight && "h-full min-h-0",
)}
style={{ backgroundColor: frameColor }}
>
<div
aria-hidden
className="pointer-events-none absolute -top-2 right-0 left-0 h-2"
style={edgeCutStyle("top", frameColor)}
/>
<div
aria-hidden
className="pointer-events-none absolute right-0 -bottom-2 left-0 h-2"
style={edgeCutStyle("bottom", frameColor)}
/>
<div
aria-hidden
className="pointer-events-none absolute top-0 bottom-0 -left-2 w-2"
style={edgeCutStyle("left", frameColor)}
/>
<div
aria-hidden
className="pointer-events-none absolute top-0 -right-2 bottom-0 w-2"
style={edgeCutStyle("right", frameColor)}
/>
 
<div
className={cn(
"relative min-h-0 overflow-hidden bg-white",
hasFixedSize || hasFixedHeight
? "flex-1"
: (mediaClassName ?? "aspect-square"),
)}
>
<div className={cn("absolute inset-0", MEDIA_SLOT)}>
{skeleton ? (
<MediaSkeleton />
) : (
(children ?? <MediaPlaceholder />)
)}
</div>
</div>
</div>
</div>
);
},
);
 
CircleCutFrame.displayName = "CircleCutFrame";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/frames/circle-cut-frame.tsx
Platinum slotAvailable

Feature your product here.

Sticky card next to every component — highest-intent placement.

Claim this card