# wrAttributes

Web components that extend `wire.ui.WebComponent` can use the `wrAttributes` base method.  `wrAttributes` transforms all of the attributes set on a web component into a single object. The transform uses the "-" character as an object property break.  This makes it possible to use complex objects with attribute bindings.

Set up a complex object via component attributes.

```html
<my-component 
    message="Hello web components" 
    products-fruit="bananas",
    products-cookies="chocolate chip">
</my-component>
```

Transform the attributes into an object and set into a public property.

```javascript
class MyComponent extends wire.ui.WebComponent {
   
   attrib: any;   
   
   connectedCallback(){
       this.attrib = this.wrAttributes();    
   }
   
   static get templateUrl() {
       return './my-component.html';
    }
}
customElements.define('my-component', MyComponent);
```

```javascript
// this.wrAttributes();  
{
    message: "Hello web components",
    products: {
        fruit: "bananas",
        cookies: "chocolate chip"
    }
}
```

Use the object in the component template.

```html
<!-- my-component.html -->
<div>{attrib.title}</div>
<div>{attrib.products.fruit}</div>
<div>{attrib.products.cookies}</div>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wirebootstrap.com/webcomponents/wrattributes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
