#How to change theming by workspace
2 messages · Page 1 of 1 (latest)
To change the theming by workspace in a Nuxt application using Nuxt UI, you can leverage the app.config.ts file and the updateAppConfig utility. Here's how you can approach this:
- First, set up your initial theme configuration in
app.config.ts:
export default defineAppConfig({
ui: {
primary: 'green',
gray: 'cool'
}
})
- To change the theme dynamically based on the workspace, you can use the
updateAppConfigutility. Here's an example of how you might do this:
<script setup>
const appConfig = useAppConfig()
function changeThemeForWorkspace(workspaceTheme) {
const newAppConfig = {
ui: {
primary: workspaceTheme.primary,
gray: workspaceTheme.gray
}
}
updateAppConfig(newAppConfig)
}
</script>
- Call the
changeThemeForWorkspacefunction whenever you need to update the theme, such as when switching workspaces.
This approach allows you to dynamically update the primary and gray colors of your application at runtime. The changes will be reflected immediately due to the reactive nature of the app config.
For more detailed information on theming and app configuration, you can refer to: