PointerFx
A card that tilts toward a mouse pointer and lifts, or a button that leans toward it. Decorative, mouse only, and still under reduced motion. Also usePointerFx, for an element of your own in a client component.
Import
import { PointerFx } from '@nizivo/react/pointer-fx';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/pointer-fx.css';Static or interactive
Client. PointerFx and usePointerFx are one client module at @nizivo/react/pointer-fx, so
the page ships it (about 0.6 KB). It has a subpath of its own so a page that only counts numbers
with CountUp never ships it. The server renders only
data-pointer-fx, so hydration changes nothing. How to choose.
Effects
effect="tilt" (the default) turns the element up to 6 degrees toward the pointer and lifts it by
--nz-distance-lift while hovered, for a product or feature card. effect="magnetic" moves it up to
--nz-magnetic-pull toward the pointer, for a call to action. render puts it on your element:
<PointerFx render={<Card />}>. In a client component, usePointerFx({ effect }) returns the same
as props to spread: <div {...usePointerFx()}>.
How it moves
The hook writes --nz-pointer-x and --nz-pointer-y (from -1 to 1) on the element, once per
frame, and 0 when the pointer leaves; pointer-fx.css turns them into the transform. Only a mouse
that can hover moves it; touch and pen never do. Under reduced motion it writes nothing and both
tokens are 0, so the element stays still. The effect never carries meaning, and the element's
focus and click work as without it.
Examples
Basic
A product card that tilts toward the pointer and lifts, and a button that leans toward it.
€24.00
import type { JSX } from 'react';
import { Button } from '@nizivo/react/button';
import { PointerFx } from '@nizivo/react/pointer-fx';
export function PointerFxExample(): JSX.Element {
return (
<div style={{ display: 'flex', gap: 24, alignItems: 'center' }}>
<PointerFx
style={{
inlineSize: 200,
padding: 20,
borderRadius: 16,
background: 'var(--nz-bg-surface)',
border: '1px solid var(--nz-border-subtle)',
}}
>
<strong>Sand mug</strong>
<p style={{ margin: '4px 0 0' }}>€24.00</p>
</PointerFx>
<PointerFx effect="magnetic" render={<Button variant="primary" />}>
Add to bag
</PointerFx>
</div>
);
}
Props
Client component Renders no element of its own. Props: PointerFxProps. Source: src/pointer-fx/pointer-fx.client.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
effect | PointerFxEffect"tilt""magnetic" | 'tilt' | |
render | RenderProp<PointerFxState> | – | The element that moves: |
- Also takes every attribute of
<div>. (ComponentPropsWithRef<"div">)
render takes an element, or, in client code, a function of the props and this state (PointerFxState):
| Name | Type | Default | Description |
|---|---|---|---|
effectrequired | PointerFxEffect"tilt""magnetic" | – |
Other exports
PointerFxEffecttypeimport type { PointerFxEffect } from '@nizivo/react/pointer-fx'tilt: rotates toward the pointer and lifts.magnetic: moves toward the pointer.type PointerFxEffect = "tilt" | "magnetic"PointerFxHookPropstypeimport type { PointerFxHookProps } from '@nizivo/react/pointer-fx'Spread on the element:
<div {...usePointerFx()}>.Name Type Default Description data-pointer-fxrequiredPointerFxEffect"tilt""magnetic"– refrequiredRefCallback<E>– PointerFxOptionstypeimport type { PointerFxOptions } from '@nizivo/react/pointer-fx'Name Type Default Description effectPointerFxEffect"tilt""magnetic"'tilt'PointerFxPropstypeimport type { PointerFxProps } from '@nizivo/react/pointer-fx'The props of
PointerFx, listed above.PointerFxStatetypeimport type { PointerFxState } from '@nizivo/react/pointer-fx'The render state of
PointerFx, listed above.usePointerFxhookimport { usePointerFx } from '@nizivo/react/pointer-fx'function usePointerFx<E extends HTMLElement = HTMLElement>({ effect }?: PointerFxOptions): PointerFxHookProps<E>
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
This entry renders no element with a data-slot.
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
This stylesheet reads no public hook.
Layers: nz.components. Classes: . Runtime variables: --nz-pointer-x, --nz-pointer-y.
Tokens this stylesheet reads (4)
--nz-distance-lift, --nz-duration-base, --nz-easing-standard, --nz-magnetic-pull
Accessibility
Nothing in this component takes focus or keyboard input.
Keyboard
None.
Figma
Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.
- Canonical: none
- Ghost masters: none
PasswordInput
A native password input in Input's box, with a toggle that shows the password. The toggle keeps one name, "Show password", and says whether the password shows through its pressed state; a submit hides the password again.
Popover
A small dialog anchored to its trigger, for status, quick settings and filters. It has a title, a description, any controls, and a close button; Escape or a press outside closes it, and focus returns to the trigger.