Dynamic changing of themes

1 Answer 164 Views
Styling / Themes
ErL
Top achievements
Rank 1
ErL asked on 19 Jan 2023, 01:59 AM | edited on 19 Jan 2023, 02:07 AM

I'd like to have a functionality in the sample scripts to change theming using dropdown like this below:

sd

But it's not included in the sample source code. Is there a sample project that has this functionality? 

I have created a sample project using the layout tiles + this post I saw in the forums

https://stackblitz.com/edit/github-kebhl2?file=src%2FApp.js

and it looks like this:

but when I try to change dropdown its breaking:

I have attached my src code here below. can someone help me to get through this. Thank you!

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Wissam
Telerik team
answered on 19 Jan 2023, 02:49 PM

Hi,

This error is appearing because the function `changeTheme` is not defined inside `main.jsx`. You can define it, and pass it as a prop to the `ThemeChooser` component where it can be called using `props.changeTheme`. Moreover, to import the themes dynamically, you can add a link with type `stylesheet` and `href` set to a state variable `theme` just above the rendering of the `TileLayout`. This will apply the selected theme to all the tiles that are rendered inside the TileLayout.

For convenience, I have modified the project to make it functional and I am sending it as an attachment. Please check it and let us know if you have any further questions.

In addition, in order to keep the information consistent, we deleted your other thread on the same topic. Therefore, I would like to kindly ask you to continue our conversation here if any further help on this matter is needed.

Regards,
Wissam
Progress Telerik
ErL
Top achievements
Rank 1
commented on 20 Jan 2023, 12:04 AM

Thank you Wissam for the quick reply. Definitely what I'm looking to do. Also apologies for the double post, when I click submit it it broke and I thought it didn't push thru so I had to redo my post. Anyway cheers!
Wissam
Telerik team
commented on 20 Jan 2023, 09:32 AM

You are welcome. I am really glad that my reply was helpful to you and no worries about the double post.

Regards,
Wissam
Progress Telerik
Tags
Styling / Themes
Asked by
ErL
Top achievements
Rank 1
Answers by
Wissam
Telerik team
Share this question
or