Conic Background

A versatile, gradient-based background component that uses conic gradients to create smooth, directional color transitions. Perfect for adding subtle depth and visual interest to your layouts.

Conic Background

1"use client";
2
3import ConicBackground from '@/components/component-x/conic-background';
4
5export function ConicBackgroundPreview() {
6return (
7  <div className="relative w-full h-96 bg-gradient-to-b from-muted to-background rounded-lg overflow-hidden border">
8    <ConicBackground
9      position="right"
10      backgroundSpan="large"
11      angleSpan="medium"
12      colorOne="hsl(var(--primary)/0.4)"
13      colorTwo="hsl(var(--primary))"
14    />
15    <div className="relative z-10 flex items-center justify-center h-full">
16      <div className="text-center">
17        <h3 className="text-2xl font-bold text-foreground">Conic Background</h3>
18        <p className="text-muted-foreground mt-2">Smooth gradient transitions</p>
19      </div>
20    </div>
21  </div>
22);
23}
24

Installation

Run the following command to add the component:

npx cx add conic-background

Background Positions

Right

Top

Left

Bottom

1"use client";
2
3import ConicBackground, {
4type ConicBackgroundPositions,
5} from "@/components/component-x/conic-background";
6
7function capitalizeFirstLetter(str: string): string {
8if (!str) return str;
9return str.charAt(0).toUpperCase() + str.slice(1);
10}
11
12export function ConicBackgroundPositions() {
13const conicBackgroundPositions: ConicBackgroundPositions[] = [
14  "right",
15  "top",
16  "left",
17  "bottom",
18];
19return (
20  <div className="w-full h-full overflow-y-auto flex flex-col">
21    {conicBackgroundPositions.map((pos) => (
22      <div
23        key={pos}
24        className="relative flex-none w-full h-[350px] overflow-hidden border flex items-center justify-center"
25      >
26        <ConicBackground
27          position={pos}
28          backgroundSpan="large"
29          angleSpan="medium"
30          colorOne="hsl(var(--primary)/0.4)"
31          colorTwo="hsl(var(--primary))"
32        />
33        <div className="relative z-10 flex items-center justify-center h-full">
34          <h3 className="text-2xl text-foreground">
35            {capitalizeFirstLetter(pos)}
36          </h3>
37        </div>
38      </div>
39    ))}
40  </div>
41);
42}
43

Background Opacity Spans

Small

Medium

Large

1"use client";
2
3import ConicBackground, {
4type ConicBackgroundSpans,
5} from "@/components/component-x/conic-background";
6
7function capitalizeFirstLetter(str: string): string {
8if (!str) return str;
9return str.charAt(0).toUpperCase() + str.slice(1);
10}
11
12export function ConicBackgroundSpans() {
13const backgroundSpans: ConicBackgroundSpans[] = ["small", "medium", "large"];
14
15return (
16  <div className="w-full h-full overflow-y-auto flex flex-col">
17    {backgroundSpans.map((span) => (
18      <div
19        key={span}
20        className="relative flex-none w-full h-[350px] overflow-hidden border flex items-center justify-center"
21      >
22        <ConicBackground
23          position="right"
24          backgroundSpan={span}
25          angleSpan="medium"
26          colorOne="hsl(var(--primary)/0.4)"
27          colorTwo="hsl(var(--primary))"
28        />
29        <div className="relative z-10 flex items-center justify-center h-full">
30          <h3 className="text-2xl text-foreground">
31            {capitalizeFirstLetter(span)}
32          </h3>
33        </div>
34      </div>
35    ))}
36  </div>
37);
38}
39

Background Angle Spans

Small

Medium

Large

1"use client";
2
3import ConicBackground, {
4type ConicAngleSpans,
5} from "@/components/component-x/conic-background";
6
7function capitalizeFirstLetter(str: string): string {
8if (!str) return str;
9return str.charAt(0).toUpperCase() + str.slice(1);
10}
11
12export function ConicAngleSpans() {
13const angleSpans: ConicAngleSpans[] = ["small", "medium", "large"];
14
15return (
16  <div className="w-full h-full overflow-y-auto flex flex-col">
17    {angleSpans.map((span) => (
18      <div
19        key={span}
20        className="relative flex-none w-full h-[350px] overflow-hidden border flex items-center justify-center"
21      >
22        <ConicBackground
23          position="right"
24          backgroundSpan="large"
25          angleSpan={span}
26          colorOne="hsl(var(--primary)/0.4)"
27          colorTwo="hsl(var(--primary))"
28        />
29        <div className="relative z-10 flex items-center justify-center h-full">
30          <h3 className="text-2xl text-foreground">
31            {capitalizeFirstLetter(span)}
32          </h3>
33        </div>
34      </div>
35    ))}
36  </div>
37);
38}
39