Background
Documentation Index
Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.
Style chart backgrounds with built-in and custom patterns.
Usage
<EvilLineChart
xDataKey="month"
data={data}
chartConfig={chartConfig}
backgroundVariant="dots"
/>Variants
Dots
backgroundVariant='dots'
Grid
backgroundVariant='grid'
Cross Hatch
backgroundVariant='cross-hatch'
Diagonal Lines
backgroundVariant='diagonal-lines'
Plus
backgroundVariant='plus'
Falling Triangles
backgroundVariant='falling-triangles'
4-Pointed Star
backgroundVariant='4-pointed-star'
Tiny Checkers
backgroundVariant='tiny-checkers'
Overlapping Circles
backgroundVariant='overlapping-circles'
Wiggle Lines
backgroundVariant='wiggle-lines'
Bubbles
backgroundVariant='bubbles'
Custom Variant
Add your own style: define an SVG <pattern> and register it as a variant.
- Add the new name to the
BackgroundVariantunion insrc/registry/ui/background.tsx. - Create a pattern component that returns a
<pattern>with your SVG shapes. - Register the pattern component in
PATTERN_MAP.
Example custom pattern:
export type BackgroundVariant =
| "dots"
| "grid"
| "cross-hatch"
| "custom-pattern";
// ...other variants
const CustomPattern = ({ id }: { id: string }) => (
<pattern
id={id}
x="0"
y="0"
width="24"
height="24"
patternUnits="userSpaceOnUse"
>
<path
className="text-border dark:text-border"
d="M12 2l2.2 4.6L19 9l-4.8 2.4L12 16l-2.2-4.6L5 9l4.8-2.4L12 2z"
fill="currentColor"
fillOpacity="0.35"
/>
</pattern>
);
const PATTERN_MAP: Record<BackgroundVariant, React.FC<{ id: string }>> = {
dots: DotsPattern,
grid: GridPattern,
"cross-hatch": CrossHatchPattern,
"custom-pattern": CustomPattern,
// ...other variants
};
Then use it in any chart:
<EvilLineChart
xDataKey="month"
data={data}
chartConfig={chartConfig}
backgroundVariant="custom-pattern"
/>Note
Tip: Use your logo as a pattern. Swap the SVG shape for an <image> pointing to your logo, then
control its size and transparency: <image href="/logo.svg" width="24" height="24" opacity="0.2" />.