Custom Object Properties

Map custom object properties using member attributes

Live Demo
Instructions

This example uses custom property names from user objects:

{
  userId: 1,
  fullName: 'John Doe',
  email: 'john@example.com',
  role: 'Admin'
}

Member attributes tell the component which properties to use for values, display text, and subtitles.

Properties
Member Attributes

value-member="userId" - Use userId as unique identifier

display-value-member="fullName" - Show fullName as main text

subtitle-member="email" - Show email below name

[key, value] Tuples

Auto-detected tuple arrays - no configuration needed

Live Demo
Instructions

Provide an array of [key, value] tuples - no configuration needed!

[
  [1, 'Option One'],
  [2, 'Option Two'],
  [3, 'Option Three']
]

The first element is used as the value, the second as display text.

Auto-Detection
Automatic Detection

When the component detects tuples (arrays with exactly 2 elements), it automatically:

  • Uses index 0 as the value
  • Uses index 1 as display text

No member attributes required!

Callback Functions

Use callbacks for complex data extraction logic

Live Demo
Instructions

This example uses deeply nested objects with complex structure:

{
  data: {
    id: 'usr_1',
    info: {
      name: 'Product A',
      price: 99.99,
      category: 'Electronics'
    }
  }
}

How to use callbacks:

const select = document.querySelector('web-multiselect');
select.options = complexData;

select.getValueCallback = (item) => {
  return item.data.id;
};

select.getDisplayValueCallback = (item) => {
  return item.data.info.name;
};

select.getSubtitleCallback = (item) => {
  return `$${item.data.info.price} - ${item.data.info.category}`;
};

select.getIconCallback = (item) => {
  return item.data.info.category === 'Electronics' ? '🔌' : '📚';
};

select.getBadgeDisplayCallback = (item) => {
  return `${item.data.info.name} ($${item.data.info.price})`;
};
Callbacks
Callback Properties

getValueCallback - Extract unique value from item

getDisplayValueCallback - Extract display text for dropdown

getBadgeDisplayCallback - Extract display text for pills (optional)

getSubtitleCallback - Extract subtitle text

getIconCallback - Extract or generate icon

Callbacks receive the full item object and can return any computed value. Use callbacks when you need complex logic or deeply nested property access.

Note: In this example, pills show "Product A ($99.99)" while dropdown shows full details with category.