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

# Detecting Component Mappings

You can detect whether a component is part of a template by 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, for example, created directly using one of its constructors.

**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 isn’t part of a template.

See [Binding Template Components](https://vaadin.com/docs/next/flow/component-internals/templates/components.md) for more about `@Id` mappings.

`83A3B417-98D0-4FEE-BF95-EFF60C67D49C`
