Skip to main content

ConfigurableListAttributeController

You get this controller when useAttribute(...) resolves a configurable list attribute — a set of selectable value entities (for example a dropdown or a list of options). You select one by its cid.

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

const attribute = useAttribute(configurator, attributeCid);

Selecting a value

Look up the value entity you want (from values or allValues) and pass its cid to setValue(...).

// Select the first available option
const [firstOption] = attribute.values;

if (firstOption) {
attribute.setValue(firstOption.cid);
}

API

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

setValue(cid: string)

Selects the list value entity whose cid matches, storing its config.value as the configured value. An unknown cid results in an empty selection.

attribute.setValue(optionCid);

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