Open Closed

LeptonX - Remove Some Theme Options Under Appearance #10914


User avatar
0
kkmy created

Hello,

I want to remove some theme options under the Appearance part that is in the side bar. Specifically, I want to remove all options except Light. I have managed to remove all options except System. What should I do?

Configure<LeptonXThemeOptions>(options =>
{
    options.DefaultStyle = LeptonXStyleNames.Light;

    options.Styles.Remove(LeptonXStyleNames.Dark);
    options.Styles.Remove(LeptonXStyleNames.Dim);
    options.Styles.Remove(LeptonXStyleNames.System);
});
import { LPX_THEMES, LPX_THEME_STYLES_DEFAULTS, lightTheme } from '@volosoft/ngx-lepton-x';

// LPX_THEME_STYLES_DEFAULTS list does not have the System option.
const lightOnlyThemes = LPX_THEME_STYLES_DEFAULTS
  .filter(theme => theme === lightTheme)
  .map(theme => ({ ...theme, defaultTheme: true }));
  
export const appConfig: ApplicationConfig = {
  providers: [
    importProvidersFrom(
      ...
      ThemeLeptonXModule.forRoot({
        defaultTheme: 'light'
      }),
      ...
    ),
    {
      provide: LPX_THEMES,
      useValue: lightOnlyThemes
    },
    ...
  ]
};

Thank you.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • In Angular LeptonX, the “System” option you still see under Appearance is not coming from LPX_THEME_STYLES_DEFAULTS (as you noticed). It is added by the theme’s style registry / appearance component logic, so removing it from LeptonXThemeOptions (server-side) or filtering LPX_THEME_STYLES_DEFAULTS (client-side) is not sufficient by itself.

    • The reliable way to keep only Light is:

      1. Force Light at runtime (so System can’t take effect), and
      2. Replace/hide the Appearance style switcher UI (since the built-in UI will still offer “System”).

    1) Force Light style at runtime (Angular)

    Put this in your app.component.ts (or an app initializer) so the selected style is always Light:

    import { Component } from '@angular/core';
    import { ThemeService, StyleNames, lightTheme } from '@volosoft/ngx-lepton-x';
    
    @Component({
      selector: 'app-root',
      template: '<abp-dynamic-layout />',
    })
    export class AppComponent {
      constructor(private themeService: ThemeService) {
        if (this.themeService.selectedStyle?.styleName !== StyleNames.Light) {
          this.themeService.setTheme(lightTheme);
        }
      }
    }
    

    This matches an accepted solution from ABP support content and prevents “System” from being applied based on OS/browser preference.

    2) Remove “Appearance” options from the UI (Angular)

    Since “System” is injected by the UI layer, you need to override/replace the related LeptonX component that renders the appearance options (or hide it via a component replacement). In LeptonX Angular, this is done via ABP’s ReplaceableComponentsService (the mechanism is referenced in ABP’s LeptonX customization guidance). Practically:

    • Create your own component that does not render the style list (or renders only Light / nothing).
    • Register it with ReplaceableComponentsService using the appropriate LeptonX component key.

    (There isn’t a verified, official doc snippet in the available context that names the exact “Appearance” component key for Angular; so the definitive, verified approach is: force Light + replace that UI component via ReplaceableComponentsService.)

    Notes on your current code

    • Your backend Configure<LeptonXThemeOptions> snippet is correct for MVC/Blazor theme option control, but Angular’s selectable list is client-driven, so it won’t fully control what the Angular Appearance UI shows.
    • Your LPX_THEMES provider override is fine, but it won’t remove the “System” entry if it’s not sourced from LPX_THEME_STYLES_DEFAULTS.

    Sources

    • https://abp.io/support/questions/5566 ✅
    • https://abp.io/docs/latest/ui-themes/lepton-x/mvc ✅

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi,

    The System option is not in LPX_THEMES. The theme service adds it on its own, so filtering the list doesn't remove it. You can turn it off with disableSystemOption:

    ThemeLeptonXModule.forRoot({
      defaultTheme: 'light',
      themeOptions: {
        localStorageKey: 'LPX_THEME',
        disableSystemOption: true,
      },
    }),
    

    Keep your LPX_THEMES provider as it is. localStorageKey is required when you pass themeOptions, and LPX_THEME is its default value.

    Thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on October 08, 2026, 12:23
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.