useBreathing

Returns a CSS animation style object with a randomized delay for the breathing animation. Each instance gets a unique delay so elements don't pulse in sync.

Usage

import { useBreathing } from "@bloomkit/react";
 
export function PulsingOrb() {
  const breathingStyle = useBreathing();
 
  return (
    <div
      style={breathingStyle}
      className="w-16 h-16 rounded-full bg-[var(--bloom-accent1)]"
    />
  );
}

Options

OptionTypeDefaultDescription
durationnumber6Animation cycle duration in seconds
animationstring"bloom-breathe"Keyframe animation name to use

Return value

PropertyTypeDescription
animationNamestringName of the keyframe animation
animationDurationstringDuration string, e.g. "6s"
animationDelaystringRandomized delay string, e.g. "2.47s"
animationTimingFunctionstringAlways "ease-in-out"
animationIterationCountstringAlways "infinite"

The return value can be spread directly onto the style prop of any element.

Custom duration

Pass a duration option to slow down or speed up the rhythm:

import { useBreathing } from "@bloomkit/react";
 
export function SlowPulse() {
  const breathingStyle = useBreathing({ duration: 10 });
 
  return (
    <div
      style={breathingStyle}
      className="w-24 h-24 rounded-full bg-[var(--bloom-accent3)]"
    />
  );
}

Custom animation name

If you define your own keyframes, pass the name via the animation option:

import { useBreathing } from "@bloomkit/react";
 
export function CustomPulse() {
  const breathingStyle = useBreathing({ animation: "my-pulse", duration: 4 });
 
  return <div style={breathingStyle} className="w-12 h-12 rounded-full" />;
}