As I work on developing a custom component using StencilJS, I find myself needing to adjust the outline behavior when users navigate through it with either a keyboard or mouse.
My component employs ShadowDOM and I aim to extract an HTML tag attribute from the CSS styling.
To capture keyboard and mouse events, the attributes of the tag are populated by what-input (https://github.com/ten1seven/what-input).
I experimented with CSS Selectors such as [data-whatintent=keyboard]
and html[data-whatintent=keyboard]
, but unfortunately, they did not yield the desired results.
This is the snippet of my HTML tag where the data-whatintent
attribute resides:
<html dir="ltr" lang="en" data-whatinput="keyboard" data-whatintent="mouse">
<my-custom-component></my-custom-component>
</html>
Below is an excerpt from my CSS file:
[data-whatintent=keyboard] *:focus {
outline: solid 2px #1A79C6;
}
It is essential for me to leverage the value of the data-whatintent
attribute in my ShadowDOM CSS rules to effectively style the component's outline according to my specifications.