Compare is one before/after control, composed from three auxiliary piecesโnot four different comparators. Import NeuCompareComponent, NeuCompareItemComponent, NeuCompareIndicatorComponent and NeuCompareHandleComponent from @neural-ui/core/compare. The complete examples on this page show how they fit together. The same coastal illustration is grayscale before and in color after; those image styles belong to the application.
Use two CompareItem children, one CompareIndicator and one CompareHandle. position="before" or "after" identifies each surface. Accept valueChange by assigning $event.value to the applied value; defaultValue is a fallback, not persistent local state. The indicator and handle inherit the parent orientation and position and must remain inside Compare.
Compose Compare with two CompareItem children, one CompareIndicator and one CompareHandle. position="before" or "after" identifies each surface. Accept valueChange by assigning $event.value to the applied value; defaultValue is a fallback, not persistent local state. The indicator and handle inherit the parent orientation and position. They must remain inside Compare. Their projected content is application-owned.
Inputs, models and Outputs are extracted from the installed Core package. Named public types link to their definitions. Templates below include executable examples.
Inputs
Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.
Name
Type
Default
Template binding
Description
defaultValue
number
50
[defaultValue]
Fallback comparison position when value is undefined; it is not a persistent uncontrolled owner.
Reports the position when a pointer or keyboard interaction completes.
Templates
ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.
Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.
Projected content
*
Projected content
Before
After
Events: 0
Public Types
Open a type to inspect its definition and interface fields.
NeuCompareOrientation.d.ts
import type { NeuCompareOrientation } from '@neural-ui/core/compare';
// Public declaration (reference only)
type NeuCompareOrientation = 'horizontal' | 'vertical';
NeuCompareValueChangeEvent.d.ts
import type { NeuCompareValueChangeEvent } from '@neural-ui/core/compare';
// Public declaration (reference only)
interface NeuCompareValueChangeEvent {
originalEvent: Event;
value: number;
}
Use the supported public tokens listed below. Surrounding layout belongs to your application; validate the result in light and dark modes and narrow containers.
Specific tokens
This component uses shared theme tokens rather than dedicated component hooks.
Shared tokens used
Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.
Token
Purpose here
Other impact
Default / fallback
--neu-focus-ring
Normal keyboard-focus ring
Shared by other Core consumers; scope the override.