Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Style the custom-element host directly from page CSS, and use the component’s public styling hooks—CSS custom properties, named parts, and slots—to customize its contents. Shadow DOM blocks ordinary page selectors from reaching arbitrary internal elements, so keep that boundary intact and expose only the styling options consumers need.

What CSS can reach across a shadow boundary?

When a custom element uses Shadow DOM, its shadow tree has a separate CSS scope. A page rule can match the host element, such as my-element, but it cannot select an arbitrary button inside that element with a selector such as my-element button. Styles defined inside the shadow tree do not ordinarily leak out to the page either. MDN summarizes the boundary this way: “The page CSS does not affect nodes inside the shadow DOM.” See MDN’s guide to using Shadow DOM and its CSS scoping guide.

This separation is useful: component authors can change internal markup without unexpectedly breaking consumer styles. Customization still works, but it should use deliberate public hooks rather than selectors that depend on private structure.

Choose the right customization hook

What you need to customize Use What it exposes
Theme values such as color, spacing, or font choices CSS custom properties A small set of values, without exposing internal elements.
A specific internal control or label part and consumer-side ::part() Only the internal elements explicitly named as parts.
Content supplied by the page <slot>, optionally with ::slotted() rules Consumer-provided light-DOM content.
Defaults or state styling on the host :host and :host(...) The custom-element host, not its internal descendants.
Styling a nested component’s selected part from outside a wrapper exportparts Only the part names the wrapper deliberately forwards.

Prefer custom properties for stable theme values, add parts when consumers need precise control of selected elements, and use slots when consumers own the inserted content. Use exportparts only when a wrapper should intentionally pass a nested component’s styling hook through another shadow boundary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Style the host from the page or inside the component

Consumers can style the host as an ordinary element. The component can set its own host defaults with :host and target host attributes or other supported conditions with :host(...). These rules affect the host, not arbitrary nodes in its shadow tree. See MDN’s reference for :host().

Component-side host defaults

:host {
  display: block;
  color: var(--my-element-color, #222);
}

:host([emphasis]) {
  font-weight: 700;
}

The first rule establishes a default display and consumes a theme token with a fallback. The second styles the host when it has the emphasis attribute.

Consumer-side host styling

my-element {
  margin-block: 1rem;
  --my-element-color: rebeccapurple;
}

Use host selectors for host-level layout and for setting documented custom properties. Avoid selectors that assume a particular internal tag or markup arrangement.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Theme internals with CSS custom properties

CSS custom properties with names such as --my-element-color inherit by default, which makes them useful for passing theme values into a shadow tree. The component reads the property in its own stylesheet and can provide a fallback with var(--property, fallback). See MDN’s guide to CSS custom properties.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/* Inside the component's shadow stylesheet */
.action {
  color: var(--my-element-color, #222);
}
/* In the page stylesheet */
my-element {
  --my-element-color: rebeccapurple;
}

Document the supported tokens and their meaning. A short, stable token set gives consumers useful theme control while allowing the component to change its internal structure.

Expose selected internals with parts

When a consumer needs to style a particular internal element—not just supply a theme value—the component can mark that element with a part name. The page can then target it using ::part(name). This is an explicit styling API: consumers can reach the named part, not gain general selector access to its descendants. See MDN’s guide to CSS shadow parts.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
/* Inside the component's shadow markup */
<button part="action">Save</button>
/* In the page stylesheet */
my-element::part(action) {
  border-radius: 0.5rem;
}

Expose only parts consumers are expected to style. A component that documents no parts or custom-property contract has not necessarily provided a way to style its internals; do not assume that an internal element is reachable just because its markup is familiar.

Forward a nested part only when needed

A part inside a nested component does not automatically become reachable through every enclosing shadow root. A wrapper must deliberately forward selected names using exportparts if outside consumers should style them. Consult MDN’s exportparts reference for the attribute syntax.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use slots for consumer-owned content

Content assigned to a slot remains in the consumer’s light DOM. Ordinary page CSS can style those supplied elements, and they retain the consumer’s tree context, including inheritance from their parent. From inside the component, ::slotted() can target assigned nodes, but it is a limited hook rather than a way to select arbitrary descendants inside those nodes. See MDN’s guide to templates and slots and its CSS scoping guide.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Use slots when the consumer should provide the markup or text itself. Use custom properties or parts when the component owns the internal element and is offering a specific way to customize it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose how to deliver shadow styles

For component styles, a <style> in a template is a direct, declarative option. A constructed CSSStyleSheet assigned through adoptedStyleSheets can be shared among multiple DOM trees; MDN describes this as creating one stylesheet and sharing it among many roots. See MDN’s Shadow DOM guide.

A stylesheet added with <link> inside a shadow tree has a rendering caveat: MDN notes that it does not block the shadow root’s paint, so content may briefly appear before those styles load. Consider that possibility when choosing external stylesheet delivery. See MDN’s guide to using custom elements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Do not treat a closed shadow root as a styling solution

With mode: "closed", accessing host.shadowRoot returns null. That setting does not provide a stronger CSS boundary than Shadow DOM already does, and MDN cautions that it is not a strong security mechanism. Keep the distinction clear: the shadow boundary scopes CSS; closed mode affects access through that property. See MDN’s Shadow DOM documentation.

A practical design rule for component authors

  • Set component defaults and host states with :host.
  • Offer custom properties for theme values expected to remain stable.
  • Expose named parts only for internal elements consumers have a real reason to style.
  • Use slots for content supplied and owned by the consumer.
  • Forward nested parts with exportparts only when the wrapper intends to support that customization.

This keeps the implementation encapsulated while making the supported customization contract visible and intentional.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.