Slider
Bounded quantity with keyboard and text alternative; steps and units are declared.
Use the web element directly without the semantic runtime.
A registered presentation adapter can bind this component to host-owned meaning and state.
The standard recipe resolver does not select this component automatically.
Import and live example#
One confidence slider at 75 percent with five-point increments.
Interactive preview requires JavaScript.
View the complete example source
import {registerAeliqoElements} from "@varendo/web";
import {
AeliqoCheckboxElement,
AeliqoComboboxElement,
AeliqoDateFieldElement,
AeliqoDateRangeElement,
AeliqoFieldGroupElement,
AeliqoFileInputElement,
AeliqoFormElement,
AeliqoNumberFieldElement,
AeliqoRadioGroupElement,
AeliqoSearchFieldElement,
AeliqoSelectElement,
AeliqoSliderElement,
AeliqoSwitchElement,
AeliqoTextAreaElement,
AeliqoTextFieldElement,
type AeliqoOption,
} from "@varendo/web/inputs";
const options: readonly AeliqoOption[] = [
{value: "ada", label: "Ada Lovelace", description: "Research"},
{value: "grace", label: "Grace Hopper", description: "Product"},
{value: "lin", label: "Lin Chen", disabled: true},
];
registerAeliqoElements();
const host = document.querySelector<HTMLElement>("#aeliqo-example") ?? (() => {
const created = document.createElement("div");
created.id = "aeliqo-example";
(document.body ?? document.documentElement).append(created);
return created;
})();
function createCatalogRoot(container: HTMLElement): HTMLElement {
const root = document.createElement("div");
root.dataset.catalogSourceRoot = "true";
root.style.display = "grid";
root.style.gap = "12px";
container.append(root);
return root;
}
function createCatalogElement<T extends HTMLElement>(tagName: string, container: HTMLElement): T {
const element = document.createElement(tagName) as T;
element.setAttribute("data-aeliqo-theme", "light");
container.append(element);
return element;
}
function appendSlottedText(root: HTMLElement, slot: string, textContent: string): void {
const content = document.createElement("span");
content.slot = slot;
content.textContent = textContent;
root.append(content);
}
const root = createCatalogRoot(host);
(((root) => {
const element = createCatalogElement<AeliqoSliderElement>("aeliqo-slider", root);
element.label = "Confidence";
element.name = "confidence";
element.min = 0;
element.max = 100;
element.step = 5;
element.value = 75;
element.unit = "%";
}))(root);
Purpose#
A native range control paired with an editable numeric field for one bounded quantity. The host can
set value; either control updates that local property and shows its unit. min, max, and step
constrain edits, while the host decides what to retain or persist.
When to use it#
- People adjust a quantity inside declared bounds, such as volume or confidence.
- A range is useful, but people also need to enter an exact value directly.
- The current value and unit should stay visible beside the track and numeric field.
When to use a different component#
- Use NumberField when a range control would not help people choose the value.
- Use Form when the value submits alongside other fields.
Properties and defaults#
The host supplies numerical bounds and unit; each change is a proposal for host state.
| Property | Use and ownership | Declared type | Initial value |
|---|---|---|---|
label | Provides the visible label and accessible name for the component. | string | '' |
description | Provides supporting text associated with the control or value. | string | '' |
error | Provides the current validation or operation error associated with the control. | string | '' |
required | Marks the control as required for validation and native accessibility semantics. | boolean | false |
disabled | Prevents user interaction while keeping the control and its current value visible. | boolean | false |
readOnly | Keeps the current value focusable and readable while preventing edits. | boolean | false |
name | Provides the stable form or action name used by the host to identify this control. | string | '' |
autocomplete | Passes an autocomplete purpose to the native input so browsers can offer an appropriate saved value. | string | 'off' |
locale | Selects locale-sensitive formatting and parsing behavior. | string | 'en-US' |
validationState | Controls the current idle, pending, valid, or invalid validation state. | AeliqoValidationState | 'idle' |
validator | Runs host-provided synchronous validation for a proposed input value. | AeliqoValidator<T> | undefined | undefined |
value | Controls the current value. Apply accepted user proposals back to this property. | number | 0 |
defaultValue | Provides the initial uncontrolled value. Later updates come from component interaction. | number | 0 |
min | Sets the lower bound for min. | number | 0 |
max | Sets the upper bound for max. | number | 100 |
step | Sets the permitted numeric or split-position increment. | number | 1 |
unit | Provides the unit label associated with the numeric value. | string | '' |
Events#
| Event | Payload | Emitted | Application responsibility |
|---|---|---|---|
aeliqo-input-change | {source, value, composing?} | Whenever the user proposes a draft value change. | Validate or store the draft and reassign controlled value or checked state. |
aeliqo-input-commit | {source, value} | After explicit commit, blur, or Enter where the control supports it. | Accept or reject the committed value and update authoritative form state. |
aeliqo-validation | {source, state, message} | When validation enters pending, valid, or invalid state. | Merge the result with application validation and display authoritative errors. |
Events cross the component boundary as user proposals. Validate their detail and current authority before applying a business effect.
Listen for aeliqo-input-change
const element = document.querySelector('aeliqo-slider');<p>element?.addEventListener('aeliqo-input-change', (event) => {
const proposal = (event as CustomEvent<unknown>).detail;
// Validate the proposal, update host state, then assign controlled properties.
applyProposal(proposal);
});Listen for aeliqo-input-commit
const element = document.querySelector('aeliqo-slider');</p>
<p>element?.addEventListener('aeliqo-input-commit', (event) => {
const proposal = (event as CustomEvent<unknown>).detail;
// Validate the proposal, update host state, then assign controlled properties.
applyProposal(proposal);
});Listen for aeliqo-validation
const element = document.querySelector('aeliqo-slider');</p>
<p>element?.addEventListener('aeliqo-validation', (event) => {
const proposal = (event as CustomEvent<unknown>).detail;
// Validate the proposal, update host state, then assign controlled properties.
applyProposal(proposal);
});States and failure handling#
Relevant states:
- ready
- disabled
- invalid
- pending
Expected result: The value remains on the declared step grid and is announced with its unit.
Changing value or unit or replacing validator cancels validation for the
previous value and clears its validator-owned error. An independently supplied
host error survives the change. Late results after a reset or disconnect are
ignored.
Keyboard, focus, and accessibility#
Keyboard behavior:
- Tab
- Arrow keys
- Page Up and Page Down
- Home and End
Exposed semantics:
- aria-describedby
- aria-invalid
- aria-label
- aria-readonly
- input
- role
Responsive behavior#
Give the track its own row in narrow forms. Keep its numeric label and unit visible as the viewport shrinks.
Style hooks#
- Shadow parts:
description,error,field,input,label,pending,text-input,unit - Varendo design tokens referenced:
--aeliqo-color-accent,--aeliqo-control-min-target,--aeliqo-space-8
Related components#
Generated TypeScript declaration#
View generated declaration
export declare class AeliqoSliderElement extends AeliqoFieldElement<AeliqoSliderValue> {
static readonly properties: {
label: {
type: StringConstructor;
};
description: {
type: StringConstructor;
};
error: {
type: StringConstructor;
};
required: {
type: BooleanConstructor;
reflect: boolean;
};
disabled: {
type: BooleanConstructor;
reflect: boolean;
};
readOnly: {
attribute: string;
type: BooleanConstructor;
reflect: boolean;
};
name: {
type: StringConstructor;
reflect: boolean;
};
autocomplete: {
type: StringConstructor;
};
locale: {
type: StringConstructor;
};
validationState: {
attribute: string;
type: StringConstructor;
reflect: boolean;
};
validator: {
attribute: boolean;
};
value: {
type: NumberConstructor;
reflect: boolean;
};
defaultValue: {
attribute: string;
type: NumberConstructor;
};
min: {
type: NumberConstructor;
};
max: {
type: NumberConstructor;
};
step: {
type: NumberConstructor;
};
unit: {
type: StringConstructor;
};
};
value: number;
defaultValue: number;
min: number;
max: number;
step: number;
unit: string;
connectedCallback(): void;
protected updated(): void;
protected isCurrentValidationValue(value: AeliqoSliderValue): boolean;
protected resetField(): void;
protected render(): import("lit").TemplateResult<1>;
focus(options?: FocusOptions): void;
private readonly handleRange;
private readonly handleText;
private readonly handleCommit;
private applyUserValue;
private isValid;
private safeStep;
private safeNumber;
private nativeRange;
private syncNative;
static readonly styles: import("lit").CSSResult[];
}Version#
This page documents the Varendo 0.6 component contract.
