Web · Components
EffectLayer
Client layer of effects.
Live example
Preview
Card
How long does shipping take?
How do I return an item?
Code
Events
- Events appear here when you interact with the preview.
Effects on your own element: getEffects
Import
Client layer of effects. Placed inside the element with effects and binds listeners to its parent (the owner of the effect); also works inside server components (Card, Badge):
- Pointer tracking (
glow,tilt, custom effects withpointer: true): writes the pointer position to the--ui-effect-x/y(pixels) and--ui-effect-px/py(-1…1 relative to the center) variables. Light and tilt are drawn entirely in CSS; React doesn't re-render. Writes are reduced to one per frame and, since layers only changetranslate/transform, they are composited without painting. No listeners are bound on touch screens; the element doesn't move while scrolling. - Press (
ripple,pulse,bounce, custompress): plays from the pressed point on mouse/touch press and from the center on keyboard. Doesn't play on disabled elements or with the "reduce motion" preference. - Custom setup (
setup): called when the element appears and cleaned up when it is removed.
To add effects to your own component, give the element data-effect and put this inside it; or use EffectParts.
The measured box (getBoundingClientRect) changes slightly while the element rotates, so the position is computed from offsetWidth/Height, which rotation doesn't affect, and the box center. That way tilt doesn't feed back into the pointer position and jitter.
Decoration layers placed inside an element with effects: the rotating beam (beam), the shine (shine) and, where needed, the pointer/press layer (EffectLayer). The element itself must carry the data-effect attribute; see getEffects.
getEffects
functionAdds the library's effects to your own element or component. Also works in server components. The element must be positioned (relative); effect layers take the element's corner radius.
Examples
mergeAppearance
functionMerges two appearance settings; next wins.
defineAppearance
functionDefines the app's appearance settings and registers them app-wide: component defaults, custom effects and custom variants. Returns the same object; pass it to the UIProvider appearance prop and register it with the Register interface so the names are type-checked.
Server components (Card, Badge…) can't read context; they take the settings from this registry. In Next.js App Router, import the settings file in the root layout (server-side registration) and pass it to the provider (client side). Custom effects containing functions (press, setup) can't be passed from server to client; if you have such effects, also import the file in your client provider file.
Examples
getAppearance
functionReturns the app-wide appearance settings. For server components and code outside components; in client components use useAppearance, which also sees nested providers.
EffectLayerProps
interfaceProps of the EffectLayer component.
| Name | Type | Description |
|---|---|---|
effects | string | Effects to run, space-separated (e.g. "tilt glow ripple"). |
EffectPartsProps
interfaceProps of the EffectParts component.
| Name | Type | Description |
|---|---|---|
effects | readonly string[] | Effects to run. |
appearance? | AppearanceConfig | Settings from which custom effects are read. Defaults to the app-wide registry (getAppearance). |
GetEffectsOptions
interfacegetEffects options.
| Name | Type | Description |
|---|---|---|
component? | EffectComponent | Component key whose default is read from UIProvider appearance.defaults (e.g. "card"). |
fallback? | EffectInput | Effect to use when there is neither a prop nor a provider default. |
appearance? | AppearanceConfig | Settings. In a client component pass useAppearance(); otherwise the app-wide registry is used. |
EffectsResult
interfaceResult of getEffects.
| Name | Type | Description |
|---|---|---|
effects | readonly string[] | Effects to run (none and empties filtered out). |
props | { "data-effect"?: string; className?: string; } | Attributes to spread on the element: data-effect and custom effect classes. |
parts | ReactNode | Decoration layers to place inside the element. |
EffectInput
typeEffect prop; a name or an array of names. @internal
BuiltinEffect
typeThe library's built-in effects. Each effect works on every component with an effect prop (Button, Card, Badge, Alert, all form fields, Tabs, Accordion, Menu, Sidebar, Dialog, Popover, Toaster, Image, Gallery…; full list in EffectComponent) and can be combined as an array (["tilt", "glow", "ripple"]).
Played on press:
scale: sinks in slightly; CSS only.ripple: a wave spreading from the pressed point.pulse: a ring that expands outward from the element and fades.bounce: springs in and bounces back.
Active on hover, keyboard focus or while active:
lift: the element rises slightly and its shadow grows.border: the border turns the accent color.beam: a light beam rotating around the border.glow: a light following the pointer; the background and border glow where the pointer is.tilt: the element tilts in 3D toward the pointer's corner.shine: a diagonal shine passes over the element (on press on touch screens).
none: no effect; turns off theUIProviderappearancedefault.
Colors come from the element's accent color (--ui-effect-accent, the text color by default; tone on Card). With the "reduce motion" preference moving effects don't play; glow and tilt stay still on touch screens so they don't interfere with scrolling.
EffectName
typeEffect name: one of the built-in effects (BuiltinEffect) or a custom effect added with defineAppearance and registered with Register.
EffectProp
typeType of the effect prop: a single effect or effects that run together. When omitted, the component's UIProvider appearance.defaults setting is used, otherwise the component's own default. "none" turns them all off.
Examples
CustomVariant
typeNames of a custom variant in the registry. C is the component key ("button", "card"…). never when Register isn't extended.
EffectPress
interfaceInfo given to a press effect.
| Name | Type | Description |
|---|---|---|
x | number | Horizontal position of the pressed point relative to the element (pixels). Center on keyboard. |
y | number | Vertical position of the pressed point relative to the element (pixels). Center on keyboard. |
event | Event | Event that started the press: pointerdown or a keyboard click. |
EffectDefinition
interfaceCustom effect definition. One or more of three ways can be used together:
- CSS only:
classNameis added to the element (Tailwind classes or your own CSS). Also works in server components. The element also carries the effect name in itsdata-effectattribute; you can select it in CSS with[data-effect~="neon"]. - JavaScript on press:
pressis called on every press (mouse, touch or keyboard). Useelement.animate()for animation. - Free setup:
setupis called once when the element appears; bind your own listeners and return the cleanup function.
Definitions containing functions can't be passed from server to client; define them in a client file (see defineAppearance).
| Name | Type | Description |
|---|---|---|
className? | string | Classes added to the element. |
pointer? | boolean | Writes the pointer position to the --ui-effect-x/y (pixels) and --ui-effect-px/py (-1…1) variables; while the pointer is over it the element carries data-pointer. Works only on mouse devices. |
press? | (element: HTMLElement, press: EffectPress) => void | Called on every press. Not called with the "reduce motion" preference. |
setup? | (element: HTMLElement) => undefined | (() => void) | Called when the element appears; may return a cleanup function. |
Examples
VariantEntry
typeCustom variant definition. A string is classes directly; an object can derive from a built-in variant and take separate classes per color (tone).
When given under a built-in variant's name (e.g. button: { solid: "…" }), the classes are added on top of that variant.
Examples
VariantComponent
typeKeys of components that take custom variants.
button:Button,IconButton,ButtonGroupand everything that uses buttons (Dialog, Form buttons…).field: all form fields (Input,Textarea,Select,NumberInput,DatePicker…) and their*Fieldwrappers.- The others are the component of the same name (
tableOfContents→TableOfContents,otpInput→OtpInput).
ComponentDefaults
interfaceDefault appearance settings of a component.
| Name | Type | Description |
|---|---|---|
variant? | string | Default variant name: built-in or added with variants. |
effect? | EffectName | (string & {}) | readonly (EffectName | (string & {}))[] | Default effect or effects. |
tone? | Tone | Default color (if the component supports it). |
size? | Size | Default size (if the component supports it). |
shape? | string | Default corner shape (buttons only: rounded, pill, sharp). |
EffectComponent
typeKeys of components that take effects; AppearanceConfig.defaults is given with these keys.
AppearanceConfig
interfaceThe app's appearance settings: component defaults, custom effects and custom variants. Defined with defineAppearance and passed to the UIProvider appearance prop.
| Name | Type | Description |
|---|---|---|
defaults? | Partial<Record<EffectComponent, ComponentDefaults>> | Default variant, effect, tone, size, shape per component. A prop given to the component always wins. |
effects? | Readonly<Record<string, EffectDefinition>> | Custom effects: name → definition. See EffectDefinition. |
variants? | Partial<Record<VariantComponent, Readonly<Record<string, VariantEntry>>>> | Custom variants per component: name → classes. See VariantEntry. |