useAttribute Overview
useAttribute looks at an attribute's runtime type and returns the matching controller subclass, so you get type-appropriate behavior without building the controller yourself.
Common Attribute API
Every controller returned by useAttribute(...) extends the base AttributeController, so the members below are available on all attribute controllers.
StaticNumberAttributeController
You get this controller when useAttribute(...) resolves an attribute whose runtime type is a static number. Static attributes display a fixed numeric value and cannot be changed by the user.
StaticStringAttributeController
You get this controller when useAttribute(...) resolves an attribute whose runtime type is a static string. Static attributes display a fixed text value and cannot be changed by the user.
ConfigurableBooleanAttributeController
You get this controller when useAttribute(...) resolves a configurable boolean attribute. A boolean attribute is backed by value entities (typically an "on" and an "off" value); you select one by its cid.
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.
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.
ConfigurableStringAttributeController
You get this controller when useAttribute(...) resolves a configurable string attribute — a free text input. You set it directly with a string, and can read the configured character limit for validation.
Web2PrintModifierAttributeController
You get this controller when useAttribute(...) resolves a Web2Print modifier attribute. A modifier attribute adjusts a single print property (opacity, a left/right position, a border width, or a boolean flag like flip_x) and is backed by value entities that you select by their cid.
Web2PrintArtworkAttributeController
You get this controller when useAttribute(...) resolves a Web2Print artwork attribute. An artwork attribute is backed by value entities that each carry print material metadata; you select one by its cid.
Web2PrintTextAttributeController
You get this controller when useAttribute(...) resolves a Web2Print text attribute. A text attribute holds a free-input string plus formatting (font, color, offsets, rotation, scale) that the shopper edits to personalize a print.
Web2PrintGradientAttributeController
You get this controller when useAttribute(...) resolves a Web2Print gradient attribute. A gradient value holds a primary color, a secondary color, and a direction ("lefttoright" or "toptobottom"). Colors are normalized to the attribute's configured output color spaces on the way in.
Web2PrintImageAttributeController
You get this controller when useAttribute(...) resolves a Web2Print image attribute. It lets a shopper upload an image and position, scale, and rotate it on the print. The configured value stores the uploaded image id/image_url plus its transform.
Web2PrintCanvasAttributeController
You get this controller when useAttribute(...) resolves a Web2Print canvas attribute. It exposes a full canvas editing surface: add/update/remove text, image, and shape elements, reorder layers, and query the fonts and settings that back the editor. Element mutations go through a command manager, so most edits support undo/redo.
Web2PrintColorAttributeController
You get this controller when useAttribute(...) resolves a Web2Print color attribute. A color attribute stores a single chosen color and exposes the default color plus any color palettes configured for the swatch picker.
BundleProductAttributeController
You get this controller when useAttribute(...) resolves a bundle product attribute. A bundle attribute lets a shopper add other products to the configuration, optionally with per-value quantities, and supports single- or multi-select behavior.