---
title: "unmatched-host-selector"
description: "Reports a variant that tests a shadow host through the elements around it."
image: "https://stillwind.dev/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://stillwind.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# unmatched-host-selector

This rule reports a variant stack that tests a shadow host through the elements
around it, such as `host:in-[.page]:` or `host:group-hover:`. A selector in a shadow
tree cannot read those elements, so the rule never matches.

## Reported

```tsx
style.css("host:in-[.page]:block");
```

> unmatched-host-selector: `:where(:is(.page)) :host` cannot match the shadow host; pass the state down with a custom property
> 
> Example:1:17

## Fixed

```tsx
style.css("[:host(.page)]:block");
```

## How to fix

- Add a class or an attribute to the host, and test it inside `:host()`, as in the
  example.
- Set a custom property on the outer element, and read it on the host with
  [`--if()`](https://stillwind.dev/docs/guides/runtime-conditions). Custom properties inherit into a
  shadow tree.

## Rule settings

| Preset | Severity |
| --- | --- |
| `recommended` | warn |
| `strict` | deny |
| `stylistic` | off |

[Configure lint](https://stillwind.dev/docs/configuration#lint) to change the severity or options.

Source: https://stillwind.dev/docs/lints/unmatched-host-selector/index.mdx
