Refractive glass effects for React components
Refractive is a higher-order component (HOC) that wraps any React component to apply refractive glass effects. The HOC uses SVG filters to create the effect, applied via the backdrop-filter CSS property.
The package is published to npm at @hashintel/refractive.
npm install @hashintel/refractive
Or using Yarn:
yarn add @hashintel/refractive
react ^19.0.0react-dom ^19.0.0The package itself has zero runtime dependencies.
The refractive export can either be used as a namespace of refractive HTML elements (refractive.div, refractive.span, etc.) or as a function that wraps any React component.
The refraction prop customises the appearance of the effect.
Style overrides
refractive will override style.backdropFilter and style.borderRadius of the wrapped component.
divimport { refractive } from "@hashintel/refractive";
<refractive.div
className="your-class-name"
refraction={{
radius: 12,
blur: 4,
bezelWidth: 10,
}}
>
Your content here
</refractive.div>;
import { refractive } from "@hashintel/refractive";
import { Button } from "./button";
const RefractiveButton = refractive(Button);
<RefractiveButton
onClick={() => {}}
refraction={{
radius: 8,
blur: 2,
bezelWidth: 8,
}}
>
Click Me
</RefractiveButton>;