setting MaterialDesign desktop theme in JS from pre compiled theme.css

36 Views Asked by At

I used Angular 1 years ago but everything has changed....so I feele like an idiot. I'm using a material design implementation from "unpkg" in a simple desktop based javascript web application. without SCCS, React, etc.

Trying to activate a theme compiled using the theme builder at https://m3.material.io/theme-builder but there are no examples of how to put it into use.

In a simple single page app I have included the unpkg material components like so, following their readme, and a theme package created using the Material site's theme builder

<link rel="stylesheet" href="https://unpkg.com/material-components-web@latest/dist/material-components-web.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet"** href="/xxxx/assets/css/theme.css"**>
<script type="text/javascript"
   src="https://unpkg.com/material-components-web@latest/dist/material-components-web.js">
</script>
<script type="text/javascript"
   src="https://unpkg.com/material-components-web@latest/dist/index.js">
</script>
<link type="text/javascript" src="/xxxxx/assets/app.js">
<html>
....
</html>
<script>mdc.autoInit()</script>

But I don't know how/where to put the compiled theme into action. I just get the default theme within the material components within the page. One issue is that while the theme builder explicitly says its for m3, I don't know what version of Material unpkg is giving me. The only example I can find is in back-end code in a c# application. This is an entirely front-end generated UI.

1

There are 1 best solutions below

1
On

The theme compiled by the theme builder is not compatible with material-components-web. material-components-web is M2 implementation. At the moment there is no M3 web implementation, only work in progress - https://m3.material.io/develop/web