HTML exportparts Attribute

Beginner
6 min read
Updated: Nov 2026
3 examples
Live preview

Definition and Usage

The exportparts global attribute re-exports CSS parts from a nested shadow tree so an outer page (or outer host) can style them with ::part(). Without it, parts stop at the inner shadow boundary.

Put part on the inner nodes, then list those names on the nested host with exportparts. Optionally rename with inner:outer mappings.

Composition helper.

Ideal when a wrapper component embeds another themed element and still wants a flat styling API.

Inner parts must exist first.

exportparts only forwards names that the nested tree actually exposes via part.

HTML Syntax

syntax.html
<element exportparts ="part[, inner:outer…]">

Comma-separated list. Same name forwards unchanged; inner:outer renames for consumers.

Attribute Values

ValueDescriptionTry it
labelForward inner part label as labelTry it
label:titleForward label under the outer name titleTry it
a, b:cMix same-name and renamed exportsTry it

Live Preview

An outer wrapper re-exports an inner button label. Toggle outer ::part styling.

Inner part="label" is forwarded via exportparts="label".

Result

exported ::part off

HTML Examples

Example 1 — Forward Nested Parts

Re-export so the page can style the nested label.

HTML
<!-- Outer shadow embeds: -->
<inner-btn exportparts="label"></inner-btn>

<!-- Page CSS: -->
<style>
  outer-wrap::part(label) { color: teal; }
</style>
Try It Yourself

How It Works

  1. Inner node has part="label".
  2. Nested host lists exportparts="label".
  3. Outer page styles outer::part(label).
  4. Without exportparts the outer selector would miss.

Example 2 — Rename When Exporting

Map an internal name to a clearer public name.

HTML
<inner-btn exportparts="label:title"></inner-btn>

<style>
  outer-wrap::part(title) { font-weight: 700; }
</style>
Try It Yourself

How It Works

  1. Left side is the inner part name.
  2. Right side is the name consumers use.
  3. Hide messy internals behind a stable public API.
  4. Document the outer names in your component docs.

Example 3 — Multiple Mappings

Forward several parts in one attribute.

HTML
<inner-panel exportparts="header, body:content, footer"></inner-panel>
Try It Yourself

How It Works

  1. Comma-separate each mapping.
  2. Mix rename and passthrough as needed.
  3. Only export what themes need.
  4. Chain carefully across multiple nesting levels.

Edge Cases & Pitfalls

Forwarding is explicit — nothing bubbles automatically.

nested

Each boundary needs exportparts

Deep nesting requires forwarding at every host that wraps another.

names

Inner name must exist

Exporting a part that was never defined with part does nothing.

rename

Consumers use the outer name

After label:title, style ::part(title), not ::part(label).

api

Public styling contract

Exported names are part of your component’s theme API.

Browser Support

exportparts is an HTML attribute for browsers. It is not a Node.js, Deno, or Bun API.

✓ Widely available

exportparts

exportparts is supported wherever CSS shadow parts work in modern browsers.

93% Global support (approx.)
Google Chrome 73+
Full support
Mozilla Firefox 72+
Full support
Apple Safari 13.1+
Full support
Microsoft Edge 79+
Full support
Opera 60+
Full support
Samsung Internet 11+
Full support
Internet Explorer No support
Not supported
exportparts Modern browsers

Bottom line: Use with part for nested Web Component themes.

Key Takeaways

  • Role: re-export nested shadow parts to the outer tree.
  • Syntax: part or inner:outer mappings, comma-separated.
  • Pair with: part on the inner nodes.
  • Consumers: style with outer-host::part(name).

One line: exportparts bubbles nested CSS parts outward so theme authors can reach them with ::part().

Frequently Asked Questions

It forwards CSS parts from a nested shadow tree so they become addressable as parts of the outer host via ::part().
On the nested custom element (the inner host) that lives inside an outer shadow tree — or on any element that hosts nested parts you want to re-export.
A comma-separated list of mappings: innerPart or innerPart:outerPart to rename when exporting.
part only exposes nodes in that shadow tree. Nested shadow parts stay private until exportparts forwards them.
Yes. Use inner:outer syntax so consumers see a stable outer name.
Yes in modern Chromium, Firefox, and Safari alongside ::part support.

Next: fetchpriority

Hint how urgently the browser should fetch an image or script.

fetchpriority tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful