Connect your React components to one shared directional light.
Requires React 18 or 19.
npm install @bolerish/edgeimport { Edge } from '@bolerish/edge';
export function Area() {
return (
<Edge.Provider>
<Edge.Surface as="article">Your card</Edge.Surface>
<Edge.Surface as="button" type="button">
Save
</Edge.Surface>
</Edge.Provider>
);
}React prepares the default styles automatically when a surface connects. For SSR, render <Edge.Styles /> once before application styles; pass your request nonce with <Edge.Styles nonce={nonce} /> when CSP requires it. Keep the same nonce during hydration. Existing @bolerish/edge/style.css imports remain supported. Only marked surfaces respond. Existing colors, layout and interactions are preserved.
Explicit Edge.Surface and useSurface connections remain supported. To discover
marked DOM descendants instead, opt in with discover:
<Edge.Provider discover surfaceOptions={{ edgeStyle: 'raised' }}>
<Button {...Edge.surface}>Save</Button>
</Edge.Provider>Edge.surface is a fixed object containing only data-edge-surface; it does not
supply classes, styles or refs. Your component must forward that attribute to its
DOM host. No CSS-tool adapter is required. surfaceOptions accepts the same
appearance options as Edge.Surface, applying only to discovered surfaces.
Discovery adds a div boundary. The nearest discovery boundary owns each marked
host, including dynamically added hosts. Portals outside the boundary are excluded;
use useSurface or Edge.Surface there. Explicit connections take priority on the
same host. A nested Provider without discover creates no DOM boundary and does not
change the outer discovery scope. Discovery connects after hydration; render
Edge.Styles for SSR. Existing pseudo-elements, overflow and stacking still need
review. Do not use discovery where the added div would make the HTML invalid.
<Edge.Provider direction="toward" range={480}>
<Edge.Surface>Your card</Edge.Surface>
</Edge.Provider>direction defaults to toward, facing highlights toward the pointer. Use away
for the opposite direction. Recessed surfaces draw the highlight one decorative
edge thickness inward while preserving the selected direction. range is the fade distance outside each surface in CSS pixels, defaults to
480, and must be positive and finite. These options affect pointer-driven lighting;
fixed lighting uses staticDirection instead. With range={40}, the effect fades to
zero when the pointer is 40 CSS pixels outside a surface. It does not limit the
bright area inside a surface to a 40-pixel circle around the pointer.
The direction values were renamed: replace gather with toward and spread
with away, and replace radius with range when upgrading from 0.3.0.
See the guides and API reference for styles, motion, integration and rendering.
See CONTRIBUTING.md for setup and checks.
MIT.