Skip to content

Commit 35ecece

Browse files
committed
main - 9c3af28 feat(material/schematics): Switch custom theme schematic to use theme mixin instead of define-theme and add high contrast override mixins (#29642)
1 parent 010355a commit 35ecece

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

docs-content/guides/schematics.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ <h3 id="material-3-theme-schematic" class="docs-header-link">
142142
<span header-link="material-3-theme-schematic"></span>
143143
Material 3 Theme schematic
144144
</h3>
145-
<p>The <code>m3-theme</code> schematic will generate a file with Material 3 themes created
146-
from custom colors.</p>
147-
<pre><code>ng generate @angular/material:m3-theme
145+
<p>The <code>theme-color</code> schematic will generate a file with Material 3 palettes from the specified colors
146+
that can be used in a theme file. It also generates high contrast color override mixins if
147+
specified.</p>
148+
<pre><code>ng generate @angular/material:theme-color
148149
</code></pre>
149-
<p>Learn more about this schematic in its <a href="https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/m3-theme/README.md">documentation</a>.</p>
150+
<p>Learn more about this schematic in its <a href="https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/theme-color/README.md">documentation</a>.</p>
150151
</div>

docs-content/guides/theming.html

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,23 +200,29 @@ <h5 id="custom-theme" class="docs-header-link">
200200
<span header-link="custom-theme"></span>
201201
Custom theme
202202
</h5>
203-
<p>Alternatively, a theme can be generated with a custom color with the following schematic:</p>
204-
<pre><code class="language-shell">ng generate @angular/material:m3-theme
203+
<p>Alternatively, custom palettes can be generated with a custom color with the following schematic:</p>
204+
<pre><code class="language-shell">ng generate @angular/material:theme-color
205205
</code></pre>
206-
<p>This schematic integrates with <a href="https://github.com/material-foundation/material-color-utilities">Material Color Utilities</a> to build a theme based on a generated set of palettes based on a single color. Optionally you can provide additional custom colors for the secondary, tertiary, and neutral palettes.</p>
207-
<p>The output of the schematic is a new Sass file that exports a theme or themes (if generating both a light and dark theme) that can be provided to component theme mixins.</p>
206+
<p>This schematic integrates with <a href="https://github.com/material-foundation/material-color-utilities">Material Color Utilities</a> to build palettes based on a single color. Optionally you can provide
207+
additional custom colors for the secondary, tertiary, and neutral palettes.</p>
208+
<p>The output of the schematic is a new Sass file that exports the palettes that can be provided to
209+
a theme definition.</p>
208210
<pre><code class="language-scss"><span class="hljs-keyword">@use</span> <span class="hljs-string">&#x27;@angular/material&#x27;</span> as mat;
209-
<span class="hljs-keyword">@use</span> <span class="hljs-string">&#x27;./path/to/m3-theme&#x27;</span>;
210-
211-
<span class="hljs-keyword">@include</span> mat.core();
211+
<span class="hljs-keyword">@use</span> <span class="hljs-string">&#x27;./path/to/my-theme&#x27;</span>; <span class="hljs-comment">// location of generated file</span>
212212

213213
<span class="hljs-selector-tag">html</span> {
214-
<span class="hljs-comment">// Apply the light theme by default</span>
215-
<span class="hljs-keyword">@include</span> mat.core-theme(m3-theme.<span class="hljs-variable">$light-theme</span>);
216-
<span class="hljs-keyword">@include</span> mat.button-theme(m3-theme.<span class="hljs-variable">$light-theme</span>);
214+
<span class="hljs-keyword">@include</span> mat.theme(
215+
<span class="hljs-attribute">color</span>: (
216+
<span class="hljs-attribute">primary</span>: my-theme.<span class="hljs-variable">$primary-palette</span>,
217+
<span class="hljs-attribute">tertiary</span>: my-theme.<span class="hljs-variable">$tertiary-palette</span>,
218+
),
219+
<span class="hljs-attribute">typography</span>: Roboto,
220+
<span class="hljs-attribute">density</span>: <span class="hljs-number">0</span>,
221+
)
217222
}
218223
</code></pre>
219-
<p>Learn more about this schematic in its <a href="https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/m3-theme/README.md">documentation</a>.</p>
224+
<p>You can also optionally generate high contrast override mixins for your custom theme that allows for
225+
a better accessibility experience. Learn more about this schematic in its <a href="https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/theme-color/README.md">documentation</a>.</p>
220226
<!-- TODO(mmalerba): Illustrate palettes with example. -->
221227

222228

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/components-examples",
3-
"version": "19.0.0-next.8+sha-a58e6f6",
3+
"version": "19.0.0-next.8+sha-9c3af28",
44
"description": "Angular Components Examples",
55
"private": true,
66
"repository": {
@@ -259,15 +259,15 @@
259259
},
260260
"homepage": "https://github.com/angular/components#readme",
261261
"peerDependencies": {
262-
"@angular/cdk": "19.0.0-next.8+sha-a58e6f6",
263-
"@angular/cdk-experimental": "19.0.0-next.8+sha-a58e6f6",
262+
"@angular/cdk": "19.0.0-next.8+sha-9c3af28",
263+
"@angular/cdk-experimental": "19.0.0-next.8+sha-9c3af28",
264264
"@angular/core": "^19.0.0-0 || ^19.1.0-0 || ^19.2.0-0 || ^19.3.0-0 || ^20.0.0-0",
265265
"@angular/common": "^19.0.0-0 || ^19.1.0-0 || ^19.2.0-0 || ^19.3.0-0 || ^20.0.0-0",
266-
"@angular/material": "19.0.0-next.8+sha-a58e6f6",
267-
"@angular/material-experimental": "19.0.0-next.8+sha-a58e6f6",
268-
"@angular/material-moment-adapter": "19.0.0-next.8+sha-a58e6f6",
269-
"@angular/material-luxon-adapter": "19.0.0-next.8+sha-a58e6f6",
270-
"@angular/material-date-fns-adapter": "19.0.0-next.8+sha-a58e6f6"
266+
"@angular/material": "19.0.0-next.8+sha-9c3af28",
267+
"@angular/material-experimental": "19.0.0-next.8+sha-9c3af28",
268+
"@angular/material-moment-adapter": "19.0.0-next.8+sha-9c3af28",
269+
"@angular/material-luxon-adapter": "19.0.0-next.8+sha-9c3af28",
270+
"@angular/material-date-fns-adapter": "19.0.0-next.8+sha-9c3af28"
271271
},
272272
"dependencies": {
273273
"tslib": "^2.3.0"

0 commit comments

Comments
 (0)