## Trait ### Properties * `id` **[String][1]** Trait id, eg. `my-trait-id`. * `type` **[String][1]** Trait type, defines how the trait should be rendered. Possible values: `text` (default), `number`, `select`, `checkbox`, `color`, `button` * `label` **[String][1]** The trait label to show for the rendered trait. * `name` **[String][1]** The name of the trait used as a key for the attribute/property. By default, the name is used as attribute name or property in case `changeProp` in enabled. * `default` **[String][1]** Default value to use in case the value is not defined on the component. * `placeholder` **[String][1]** Placeholder to show inside the default input (if the UI type allows it). * `category` **[String][1]?** Trait category. * `changeProp` **[Boolean][2]** If `true`, the trait value is applied on the component property, otherwise, on component attributes. ## getId Get the trait id. Returns **[String][1]** ## getType Get the trait type. Returns **[String][1]** ## getName Get the trait name. Returns **[String][1]** ## getLabel Get the trait label. ### Parameters * `opts` **[Object][3]** Options. (optional, default `{}`) * `opts.locale` **[Boolean][2]** Use the locale string from i18n module. (optional, default `true`) Returns **[String][1]** ## getValue Get the trait value. The value is taken from component attributes by default or from properties if the trait has the `changeProp` enabled. ### Parameters * `opts` **[Object][3]** Options. (optional, default `{}`) * `opts.useType` **[Boolean][2]** Get the value based on type (eg. the checkbox will always return a boolean). (optional, default `false`) Returns **any** ## setValue Update the trait value. The value is applied on component attributes by default or on properties if the trait has the `changeProp` enabled. ### Parameters * `value` **any** Value of the trait. * `opts` **[Object][3]** Options. (optional, default `{}`) * `opts.partial` **[Boolean][2]?** If `true` the update won't be considered complete (not stored in UndoManager). ## getDefault Get default value. ## getOptions Get trait options. Returns **[Array][4]\** ## getOption Get current selected option or by id. ### Parameters * `id` **[String][1]?** Option id. Returns **([Object][3] | null)** ## getOptionId Get the option id from the option object. ### Parameters * `option` **[Object][3]** Option object Returns **[String][1]** Option id ## getOptionLabel Get option label. ### Parameters * `id` **([String][1] | [Object][3])** Option id or the option object * `opts` **[Object][3]** Options (optional, default `{}`) * `opts.locale` **[Boolean][2]** Use the locale string from i18n module (optional, default `true`) Returns **[String][1]** Option label ## getCategoryLabel Get category label. ### Parameters * `opts` **[Object][3]** Options. (optional, default `{}`) * `opts.locale` **[Boolean][2]** Use the locale string from i18n module. (optional, default `true`) Returns **[String][1]** ## runCommand Run the trait command (used on the button trait type). [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array