How can I interact with browser-inserted Shadow DOM content in an input field?

There's no way to interact with the shadow DOM. The whole purpose of a shadow tree is to isolate functionality, behavior, and styles from the outside world - even if the mode is "open". If the author of a particular component wants you to be able to control the behavior or styles, they will provide an API for doing so. If the author does not provide an API for it, they don't want you mucking around with it.

When it comes to using form fields, my rule of thumb is to always follow one of these rules:

  1. Use the browser form fields as they come - don't try to get too fancy with it as you will likely break accessibility, keyboard navigation, autofill and other things you didn't intend to break. Anything more than styling the borders, background, and padding is usually not a good idea. You might think it is, but I can likely prove you wrong by showing how you broke some default behavior.

For example, automatically displaying a time picker would take focus away from what the user was doing. Maybe the screen reader was reading some text, or a power user was tabbing through the navigation using their keyboard, and then all the sudden they're on the time picker when they didn't want to be.

  1. Use a widely tested UI library. The authors of popular UI libraries have taken into account all of the behaviors and such so as to provide a smooth and predictable experience for users. Use these when you want to do things like automatically display a date/time picker or some other fancy behavior you probably shouldn't be doing but are going to anyways.

Whatever you do, don't try to roll your own fancy form controls. I guarantee you will piss off one of your users.


If you want to view the shadowDom in Chrome DevTools, you have to turn it on in the Settings under Elements section. You can't programmatically interact with the element except through the elements attributes and event handlers.

enter image description here

This should make the shadowroot visible

Now you can see the shadowDom

You can add change and input and event listeners to the component itself, but not the elements of the shadowDom.