animated-border.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use client";
  2. import { cn } from "@/lib/utils";
  3. interface AnimatedBorderProps {
  4. className?: string;
  5. }
  6. export const AnimatedBorder = ({ className }: AnimatedBorderProps) => {
  7. return (
  8. <>
  9. <style jsx>{`
  10. @property --angle {
  11. syntax: "<angle>";
  12. initial-value: 0deg;
  13. inherits: false;
  14. }
  15. @keyframes border-rotate {
  16. from {
  17. --angle: 0deg;
  18. }
  19. to {
  20. --angle: 360deg;
  21. }
  22. }
  23. .animate-border-mask {
  24. animation: border-rotate 2s linear infinite;
  25. mask-image: conic-gradient(
  26. from var(--angle),
  27. transparent 70%,
  28. black 90%,
  29. transparent 100%
  30. );
  31. }
  32. `}</style>
  33. <div
  34. className={cn(
  35. "pointer-events-none absolute inset-0 rounded-[inherit] animate-border-mask z-10",
  36. className,
  37. )}
  38. >
  39. <div
  40. className="absolute inset-0 rounded-[inherit] border border-blue-400"
  41. style={{
  42. boxShadow: "0 0 6px 1px #3b82f6, inset 0 0 2px 0 #3b82f6",
  43. }}
  44. />
  45. </div>
  46. </>
  47. );
  48. };