Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230805

THEME- Can I change the main.ts

$
0
0

You should be able to read in the JSON file and configure the theme at runtime. I actually just did this but with the color variables coming from our backend API.

The colors from our API look like this:

{
    "colors": [
        {
            "name": "--ion-background-color",
            "value": "#f7fdff"
        },
        {
            "name": "--ion-background-color-rgb",
            "value": "247, 253, 255"
        },
        {
            "name": "--ion-color-primary",
            "value": "#2679ac"
        },
        {
            "name": "--ion-color-primary-rgb",
            "value": "38, 121, 172"
        },
        {
            "name": "--ion-color-primary-shade",
            "value": "#0e4567"
        }
    ]
}

Then in our app during runtime:

const rootElm = document.querySelector(':root') as HTMLElement

colors.forEach(color => rootElm.style.setProperty(color.name, color.value))

Viewing all articles
Browse latest Browse all 230805

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>