Border Beam
Faisceau d'accent anime qui parcourt la bordure d'une surface mise en evidence. Installez Border Beam depuis le registre VLLNT UI avec la CLI shadcn.
Faisceau d'accent anime qui parcourt la bordure d'une surface mise en evidence. Fait partie de la famille utility dans VLLNT UI, il est publie comme entree de registre lisible par machine — copiez la source directement dans votre application avec la CLI shadcn et possedez-la, sans dependance d'execution a une bibliotheque de composants.
Apercu
Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.
Installation
Ajoutez Border Beam a votre projet avec la CLI shadcn. La source arrive dans votre code, prete a etre adaptee :
pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/border-beam.jsonSource
import * as React from "react";
import { cn } from "../../lib/utils";
export type BorderBeamProps = React.ComponentPropsWithoutRef<"span"> & {
borderWidth?: number;
colorFrom?: string;
colorTo?: string;
delay?: number;
duration?: number;
reverse?: boolean;
};
export const BorderBeam = ({
borderWidth = 1,
className,
colorFrom = "oklch(var(--primary) / 0.85)",
colorTo = "oklch(var(--ring) / 0.25)",
delay = 0,
duration = 6,
ref,
reverse = false,
style,
...props
}: BorderBeamProps & { ref?: React.Ref<HTMLSpanElement> }) => {
const beamStyle: React.CSSProperties = {
animationDelay: `${delay}s`,
animationDirection: reverse ? "reverse" : "normal",
animationDuration: `${duration}s`,
animationIterationCount: "infinite",
animationName: "vllnt-border-beam-angle",
animationTimingFunction: "linear",
background: `conic-gradient(from var(--vllnt-border-beam-angle, 90deg), transparent 0deg, transparent 220deg, ${colorFrom} 280deg, ${colorTo} 335deg, transparent 360deg)`,
borderRadius: "inherit",
boxSizing: "border-box",
mask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
maskComposite: "exclude",
padding: `${borderWidth}px`,
WebkitMask:
"linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
WebkitMaskComposite: "xor",
...style,
};
return (
<span
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 rounded-[inherit]",
className,
)}
ref={ref}
style={beamStyle}
{...props}
/>
);
};
BorderBeam.displayName = "BorderBeam";
Stories
Explorez chaque variante et etat dans le Storybook interactif :
Apercu
Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.