Skip to content

Customization

AWC UI components support three progressively powerful customization methods:

  1. CSS Custom Properties — change colors, shapes, sizes without breaking encapsulation
  2. CSS Shadow Parts — directly style internal elements through ::part()
  3. Named Slots — replace entire sections of a component’s DOM

Every component exposes public CSS custom properties following the --md-{name}-{property} pattern. These pierce into shadow DOM.

<md-button
variant="filled"
style="--md-button-container-color: coral;
--md-button-label-color: white;">
Custom Colors
</md-button>
md-button.danger {
--md-button-container-color: var(--md-sys-color-error);
--md-button-label-color: var(--md-sys-color-on-error);
}
md-button.brand {
--md-button-container-color: #6200ee;
--md-button-label-color: #ffffff;
--md-button-container-shape: 8px;
}
<md-button variant="filled" class="danger">Delete</md-button>
<md-button variant="filled" class="brand">Brand</md-button>
md-button[variant="outlined"].subtle {
--md-button-outline-color: transparent;
--md-button-label-color: var(--md-sys-color-tertiary);
}

Most components expose these patterns:

PatternDescription
--md-{name}-container-colorBackground color
--md-{name}-label-colorText/label color
--md-{name}-icon-colorIcon color
--md-{name}-icon-sizeIcon dimensions
--md-{name}-container-shapeBorder radius
--md-{name}-outline-colorBorder color
--md-{name}-outline-widthBorder width

Check each component’s API Reference section for the full list.

Every styleable internal element has a part attribute, allowing direct CSS styling through the shadow boundary using ::part():

/* Style the label text */
md-button::part(label) {
text-transform: uppercase;
letter-spacing: 1.5px;
}
/* Style the icon */
md-button::part(icon) {
font-variation-settings: 'FILL' 1;
}
/* Style the state layer */
md-button::part(state-layer) {
background-color: teal;
}
/* Combine with pseudo-classes */
md-button:hover::part(label) {
text-decoration: underline;
}
/* Target specific variants */
md-button[variant="filled"]::part(icon) {
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}
PartElementAvailable On
state-layerHover/focus/press overlayAll interactive components
labelText labelButton, Chip, Tab, etc.
iconLeading iconButton, FAB, Chip, etc.
trailing-iconTrailing iconButton, Chip, Text Field
containerOuter containerCard, Dialog, etc.

Slots let you replace entire sections of a component:

Replace the default Material Symbols icon with any custom element:

<!-- SVG icon -->
<md-button variant="filled">
<svg slot="leading-icon" viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77..."/>
</svg>
Starred
</md-button>
<!-- FontAwesome icon -->
<md-button variant="outlined">
<i slot="leading-icon" class="fa-solid fa-plus"></i>
Add Item
</md-button>
<!-- Emoji -->
<md-button variant="elevated">
<span slot="leading-icon">🚀</span>
Launch
</md-button>
<md-dialog headline="Edit Profile">
<!-- Default slot: body content -->
<form>
<md-text-field variant="outlined" label="Name"></md-text-field>
</form>
<!-- Actions slot: footer buttons -->
<div slot="actions">
<md-button variant="text">Cancel</md-button>
<md-button variant="filled">Save</md-button>
</div>
</md-dialog>

For maximum control, combine all three approaches:

<style>
md-button.premium {
--md-button-container-color: linear-gradient(135deg, #667eea, #764ba2);
--md-button-label-color: white;
--md-button-container-shape: 12px;
}
md-button.premium::part(label) {
font-weight: 700;
letter-spacing: 0.5px;
}
md-button.premium::part(icon) {
filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
}
</style>
<md-button variant="filled" class="premium">
<svg slot="leading-icon" viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77..."/>
</svg>
Premium Action
</md-button>

To rebrand the entire library, override the global tokens:

:root {
/* Brand colors */
--md-sys-color-primary: #006B5A;
--md-sys-color-on-primary: #FFFFFF;
--md-sys-color-primary-container: #7CF8D8;
--md-sys-color-on-primary-container: #00201A;
/* Custom shapes */
--md-sys-shape-corner-small: 4px;
--md-sys-shape-corner-medium: 8px;
--md-sys-shape-corner-large: 12px;
--md-sys-shape-corner-full: 100px;
/* Custom typography */
--md-sys-typescale-body-large-font: 'Inter', sans-serif;
--md-sys-typescale-label-large-font: 'Inter', sans-serif;
}