Skip to main content

ConfigurableNumberAttributeController

You get this controller when useAttribute(...) resolves a configurable number attribute — a free numeric input (for example a quantity or a dimension). You set it directly with a number.

import { useAttribute } from "@expivi/product-configurator";

const attribute = useAttribute(configurator, attributeCid);

Setting a value

Pass the number straight to setValue(...):

attribute.setValue(5);

API

This controller adds no new public members. Its type-specific behavior lives in the overridden setValue(...)/parse(...):

setValue(value: number)

Writes a single numeric configured value. The controller fills in the value's min/max from the attribute's settings (falling back to 0 / Infinity), and applies defaults for decimalPlaces (0) and step (1). If value is nullish, it falls back to 0.

attribute.setValue(12);

parse(data)

When parsing serialized data, the controller reads the first serialized value, converts it with Number(...), and applies it through setValue(...).

For all other members (data, values, subscribe(...), serialize(), reset(), and more), see the Common Attribute API.