Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

CompareHandle

Provide the accessible drag and keyboard handle inside Compare.

Category
Layout and content
Import
@neural-ui/core/compare
Selector
neu-compare-handle
import { NeuCompareHandleComponent } from '@neural-ui/core/compare';

Auxiliary piece of Compare

Compare Handle is the accessible range control inside Compare, not another comparator. It inherits orientation, position, step and disabled state from its parent. Give it a meaningful ariaLabel or ariaLabelledBy, and accept valueChange on Compare. Import NeuCompareHandleComponent from @neural-ui/core/compare. Keep it inside Compare; the main guide shows the complete composition.

Complete Compare guide

Examples

Try this application-owned interaction. Its event handling and initial data are included in Code.

Examples
Coastal light before color adjustmentBefore
Coastal light after color adjustmentAfter

Events: 0

Try and configure

Change the public options, try the result and inspect the updated template. Code contains the complete executable implementation.

Try and configure
Coastal light before color adjustmentBefore
Coastal light after color adjustmentAfter

Events: 0

template.html
<neu-compare
  class="remaining-compare"
  [value]="position()"
  (valueChange)="position.set($event.value)"
  (valueChangeEnd)="record('valueChangeEnd', $event.value)"
  [orientation]="'horizontal'"
  [disabled]="false"
  [slideOnHover]="false"
  [step]="5"
  ><neu-compare-item position="before"
    ><div class="remaining-compare-surface remaining-before remaining-compare-surface--image">
      <img class="remaining-compare-image" src="assets/media/coast.svg" [alt]="t('Coastal light before color adjustment', 'Luz de costa antes del ajuste de color')" width="800" height="450" draggable="false" />
      <span class="remaining-compare-caption">{{ t("Before", "Antes") }}</span>
    </div></neu-compare-item
  ><neu-compare-item position="after"
    ><div class="remaining-compare-surface remaining-after remaining-compare-surface--image">
      <img class="remaining-compare-image" src="assets/media/coast.svg" [alt]="t('Coastal light after color adjustment', 'Luz de costa despuรฉs del ajuste de color')" width="800" height="450" draggable="false" />
      <span class="remaining-compare-caption">{{ t("After", "Despuรฉs") }}</span>
    </div></neu-compare-item
  ><neu-compare-indicator
    ><span class="remaining-compare-line"></span></neu-compare-indicator
  ><neu-compare-handle
    [ariaLabel]="'Compare position'"
    ></neu-compare-handle
  ></neu-compare
>

State and events

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.

Accessibility and keyboard

Focus CompareHandle with Tab. Arrow keys adjust the position; Home/End reach the limits. Pointer dragging proposes changes through the same Outputs.

Key
Action
Tab Focus the enabled CompareHandle range control.
Arrow keys Adjust the comparison position through the range control.
Home Move to the minimum position.
End Move to the maximum position.

API

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
ariaLabelstring'Compare position'[ariaLabel]Accessible name of the control or region.
ariaLabelledBystring''[ariaLabelledBy]IDs of existing elements naming this control or region.

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.

Name
Mechanism
Contract
*

Projected content

View example
Content projection

Application-provided content.

<ng-content />

Context used: โ€”

Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.

Projected content

*

Projected content
Coastal light before color adjustmentBefore
Coastal light after color adjustmentAfter

Events: 0

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

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
No data