> Markdown version of [Detecting Mappings in Components](https://vaadin.com/docs/v14/flow/templates/polymer-templates/tutorial-component-integration). Section index: [llms.txt](https://vaadin.com/docs/v14/flow/llms.txt)

## <a id="detecting-mappings-in-components"></a>Detecting Mappings in Components

> **Note: Use Lit templates instead**
>
> Lit templates are recommended. Polymer templates are available in the next long term supported Vaadin version (LTS), but they are deprecated.

You can detect whether a component is part of a Polymer template using the `isTemplateMapped` method.

This is useful if you want to execute custom logic depending on whether the component was mapped in a template (injected via the `@Id` or `@Uses` annotations) or created directly using one of its constructors, for example.

**Example**: Calling the `isTemplateMapped` method in `MyComponent`.

```java
@Tag("div")
public class MyComponent extends Div {

  public MyComponent() {
    if (!isTemplateMapped()) {
      getElement().getStyle().set("color", "red");
    }
  }
}
```

- By default, the component only sets a style when the component is not part of a template.

See [Binding Components from a PolymerTemplate](https://vaadin.com/docs/v14/flow/templates/polymer-templates/tutorial-template-components.md) for more about To `@Id` mappings.

`482D6016-CACF-448E-B3A1-D37928E3AC65`
