# Widget attribute clarifications

**URL:** <https://meta.discourse.org/t/widget-attribute-clarifications/82870>\
**Category:** Development\
**Created:** [March 13, 2018, 3:55am UTC](https://meta.discourse.org/t/widget-attribute-clarifications/82870 "2018-03-13T03:55:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [March 13, 2018, 6:32pm UTC](https://meta.discourse.org/t/widget-attribute-clarifications/82870/3 "2018-03-13T18:32:08Z")

</div>

> [@tshenry](#):
>
> How are widget attributes established? It seems like each createWidget() has its own set of attributes and I’m having trouble tracking down where they come from and how they are determined.

There is no standard set of attributes because each widget is different. You’re most likely looking at the topic rendering, where each post receives a series of attributes. The basic post attributes are [created here](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/transform-post.js.es6#L24).

In some sub-widgets, you’ll find fewer or different attributes are passed in. You have to review the widget code to see what attributes are passed.

> [@tshenry](#):
>
> How do I get an attribute that isn’t a part of a widget’s attrs by default? For example, in the above list, how would I add trust\_level to that attribute object?

Your plugin would have to add that attribute to one of the serializers used to generate attributes. It’s probably going to go into the [post serializer](https://github.com/discourse/discourse/blob/master/app/serializers/post_serializer.rb). You should have access to it via `attrs.post.get('trust_level')` at that point.

> [@tshenry](#):
>
> Can the addition of an attribute be done in the context of a theme component or would it require a proper plugin or modifying core Discourse?

You need to a proper plugin to add an attribute to a serializer.

---

_[View the full topic](https://meta.discourse.org/t/widget-attribute-clarifications/82870)._
