Skip to content

GoodsAction ​

A product-page bottom bar: icon buttons on the left (favorites / shop / cart, with badges and pressed state) and main buttons on the right (add to cart, buy now). Data comes from the items / actions JSON attributes; every item can be disabled individually and clicks dispatch oas-action-click.

Basic usage ​

An item's key is its event identity; built-in keys (favorite / shop / cart) get default labels and icons, other keys need their own label:

Icon group + main buttons + event feedback

Click any item to see oas-action-click feedback.

Badges and pressed state ​

badge renders when greater than 0 and collapses above 99 to 99+; active marks an icon button as pressed (aria-pressed="true"), suited to favorites toggles.

Badge cap + pressed favorites

Custom icons and disabling ​

icon takes a registered icon name (built-in or registerIcon) to override the default icon; an unregistered name warns once in development and falls back to the built-in icon for that key (no built-in icon means no icon, and the text stays readable). actions[].disabled disables a single button and the host disabled disables everything:

Custom icon / single disabled / globally disabled

Primary-button loading / visual tiers ​

actions[].loading puts a single primary button into its loading state: clicks are blocked + aria-busy + spinner, orthogonal to disabled (they can coexist); actions[].type switches the visual tier (default / primary / success / warning / danger), defaulting to the primary flag. Without type the behavior is unchanged:

Per-item loading + semantic tiers

Custom icon colors ​

items[].color tints an icon button: preset names (magenta / red / volcano / orange / gold / lime / green / cyan / blue / geekblue / purple) map to the --oas-preset-<name>-text safe tokens, other values pass through as declared by the host; once colored, base / hover / pressed states stay pinned to that color:

Custom icon color

label overrides the accessible name of the navigation region (<nav>), which defaults to the i18n goodsAction.label; use it to tell several action bars on one page apart:

Custom accessible name

API ​

oas-goods-action ​

Attributes ​

AttributeDescriptionTypeDefault
actionsPrimary buttons JSON array [{ key, text, primary?, disabled?, loading?, type? }]; loading blocks clicks with aria-busy + spinner (orthogonal to disabled); type visual tier default / primary / success / warning / danger, defaults to the primary flagGoodsActionButton[] | string—
disabledDisables everything (honours config-provider injected disabled)boolean—
itemsIcon buttons JSON array [{ key, label?, icon?, badge?, active?, color? }]; built-in keys (favorite / shop / cart) fall back to built-in labels and icons; color preset names map to --oas-preset-<name>-text tokens, other values pass through as declaredGoodsActionItem[] | string—
labelNavigation accessible name, defaults to the i18n goodsAction.label——

Events ​

EventDescription
oas-action-clickDispatched when any item is clicked with { key, source: 'icon' | 'button' }, detail: { key, source } satisfies GoodsActionDetail

CSS Variables ​

CSS VariableDefault
--oas-goods-action-item-colorvar(--oas-color-text-secondary)

Released under the MIT OR Apache-2.0 License.