@protohiro/effects
v0.4.0
Published
React hooks for hard CSS effects like gradient borders, spotlight reveal, and glass highlights without wrappers.
Maintainers
Keywords
Readme
@protohiro/effects
React hooks for hard CSS effects on existing elements without wrappers.
Best for:
react gradient borderreact spotlight reveal effectreact glass highlight- composable effects in design systems
The library targets effects that are awkward to ship by hand because of pseudo-elements, border-radius, Safari fallback behavior, SSR, and ref composition.
Install
npm install @protohiro/effectsPeer dependencies:
react: ^18 || ^19react-dom: ^18 || ^19
Quick start
import { useGradientBorderEffect } from '@protohiro/effects';
export function Button() {
const ref = useGradientBorderEffect({ thickness: 2, angle: 90, animated: true });
return <button ref={ref}>Click</button>;
}Demo
Why use it
- no extra DOM nodes
- no layout measurements
- SSR and hydration friendly
- preserves existing refs and class names
- effects compose through namespaced classes and CSS variables
Hooks
useGradientBorderEffectuseGlassHighlightEffectuseGlowEffectuseNoiseEffectuseSpotlightEffect
Core effects
useGradientBorderEffect(options)
Gradient border ring on a single existing element with border-radius support and graceful fallback behavior.
Options:
thickness?: string | numberradius?: string | numbercolors?: stringangle?: string | numberanimated?: booleanspeed?: numberdisabled?: boolean
When animated is enabled, the gradient colors flow around the border with CSS only. speed is a multiplier: 1 is the default, values above 1 are faster, and values below 1 are slower. The effect respects prefers-reduced-motion and falls back to a static ring when motion is reduced.
useSpotlightEffect(options)
Interactive spotlight and reveal overlay for cards, media surfaces, and CTA blocks.
useGlassHighlightEffect(options)
Adds a restrained glass highlight layer with edge light, soft sheen, tint, and optional backdrop blur for dark premium surfaces.
Options:
color?: stringedgeOpacity?: numbersheenOpacity?: numbertintOpacity?: numberangle?: string | numberblur?: string | numberradius?: string | numberinset?: string | numbersaturate?: numberdisabled?: boolean
Live demo: protohiro.com/labs/effects
For full docs and demos, see: github.com/protohiro-com/effects
