Developers
Use Avonni components in your own LWC
Reference avonni- components in your templates, bind lists from JavaScript and handle their events.
The Avonni Components package (listed on AppExchange as Avonni LWC Components) lets you use Avonni components in the templates of your own Lightning web components. Reference them with the avonni namespace, for example <avonni-combobox>. No JavaScript import is needed.
Before you start, install the package, assign licenses in Setup under Installed Packages > Manage Licenses, and assign the package permission set to developers and end users.
- Select the LWC platform on any example, open the Code tab and copy the snippet.
- Paste the markup into your component’s HTML template. Attributes are the kebab-case form of the property names:
allowSearchbecomesallow-search. - Write text and numbers as attribute values. Write a true boolean as a bare attribute, such as
required, and leave it out when it is false: never writerequired="false", because any string value counts as true. - Set arrays and objects from JavaScript. Declare them as class fields and bind them in the template, as with
options={options}below. - Listen to events with
onattributes, such asonchange, and readevent.detail. The Events tab of each component lists its events; the comboboxchangeevent carries the selected value inevent.detail.value. - Deploy your component and add it to a page as usual.
<template>
<avonni-combobox
label="Case reason"
options={options}
placeholder="Search reasons"
allow-search
required
value={value}
onchange={handleChange}
></avonni-combobox>
</template>
import { LightningElement } from 'lwc';
export default class MyComponent extends LightningElement {
options = [
{
label: 'Billing question',
value: 'billing',
secondaryText: 'Invoices, refunds and payment methods'
},
{
label: 'Technical issue',
value: 'technical',
secondaryText: 'Errors, outages and bugs'
},
{
label: 'Account access',
value: 'access',
secondaryText: 'Login and password help'
},
{
label: 'Product feedback',
value: 'feedback',
secondaryText: 'Ideas and feature requests'
}
];
value = 'technical';
handleChange(event) {
this.value = event.detail.value;
}
}
Try it in the explorer
Combobox: Case reason