File tree Expand file tree Collapse file tree 6 files changed +39
-1
lines changed
documentation/docs/tutorial/03-Customization Expand file tree Collapse file tree 6 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,26 @@ const admin = new AdminForth({
9494Here is how it looks:
9595![ AdminForth Themes] ( image-10.png )
9696
97+ ## Single theme
98+
99+ If you want to enforce a consistent theme and disable the theme switcher, you can configure AdminForth to use only one theme variant.
100+
101+ ``` ts title='./index.ts'
102+
103+ const admin = new AdminForth ({
104+ ...
105+ customization : {
106+ // diff-add
107+ singleTheme: " light" ,
108+ styles: {
109+ ...
110+ }
111+ }
112+ },
113+ ...
114+ });
115+ ```
116+
97117
98118## Square vs rounded buttons?
99119
Original file line number Diff line number Diff line change @@ -223,6 +223,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
223223 everyPageBottom : this . adminforth . config . customization . globalInjections . everyPageBottom ,
224224 } ,
225225 rememberMeDays : this . adminforth . config . auth . rememberMeDays ,
226+ singleTheme : this . adminforth . config . customization . singleTheme ,
226227 } ;
227228 } ,
228229 } ) ;
@@ -301,6 +302,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
301302 loginPromptHTML : await tr ( this . adminforth . config . auth . loginPromptHTML , 'system.loginPromptHTML' ) ,
302303 loginPageInjections : this . adminforth . config . customization . loginPageInjections ,
303304 rememberMeDays : this . adminforth . config . auth . rememberMeDays ,
305+ singleTheme : this . adminforth . config . customization . singleTheme ,
304306 }
305307
306308 const loggedInPart = {
Original file line number Diff line number Diff line change 2424 />
2525
2626 <div class =" flex items-center ms-3 " >
27- <span
27+ <span
28+ v-if =" !coreStore.config?.singleTheme"
2829 @click =" toggleTheme" class =" cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black hover:bg-lightHtml dark:text-darkSidebarTextHover dark:hover:bg-darkHtml dark:hover:text-darkSidebarTextActive" role =" menuitem" >
2930 <IconMoonSolid class =" w-5 h-5 text-blue-300" v-if =" coreStore.theme !== 'dark'" />
3031 <IconSunSolid class =" w-5 h-5 text-yellow-300" v-else />
@@ -410,6 +411,14 @@ onBeforeMount(()=>{
410411 document .documentElement .classList .toggle (' dark' , theme .value === ' dark' );
411412})
412413
414+ watch (() => coreStore .config ?.singleTheme , (singleTheme ) => {
415+ if (singleTheme ) {
416+ theme .value = singleTheme ;
417+ window .localStorage .setItem (' af__theme' , singleTheme );
418+ document .documentElement .classList .toggle (' dark' , theme .value === ' dark' );
419+ }
420+ }, { immediate: true })
421+
413422
414423const ctaBadge: Ref <(AnnouncementBadgeResponse & { hash: string ; }) | null > = computed (() => {
415424 const badge = coreStore .config ?.announcementBadge ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export type ResourceColumns = {
2121
2222export type CoreConfig = {
2323 brandName : string ,
24+ singleTheme ?: 'light' | 'dark' ,
2425 brandLogo : string ,
2526 title : string ,
2627 datesFormat : string ,
Original file line number Diff line number Diff line change @@ -619,6 +619,11 @@ interface AdminForthInputConfigCustomization {
619619 */
620620 brandName ?: string ,
621621
622+ /**
623+ * Whether to use single theme for the app
624+ */
625+ singleTheme ?: 'light' | 'dark' ,
626+
622627 /**
623628 * Whether to show brand name in sidebar
624629 * default is true
Original file line number Diff line number Diff line change @@ -1065,6 +1065,7 @@ export interface AdminForthConfigForFrontend {
10651065 rememberMeDays : number ,
10661066 showBrandNameInSidebar : boolean ,
10671067 brandLogo ?: string ,
1068+ singleTheme ?: 'light' | 'dark' ,
10681069 datesFormat : string ,
10691070 timeFormat : string ,
10701071 auth : any ,
You can’t perform that action at this time.
0 commit comments