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

# Detecting Component Mappings

You can detect whether a component is part of a 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 annotation) 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 Template Components](https://vaadin.com/docs/v14/flow/templates/components.md) for more about To `@Id` mappings.

`1DDD66DF-1E5B-432F-9D28-6BD3B5DC3AF7`
