<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zalla Abdessamed</title>
    <description>The latest articles on DEV Community by Zalla Abdessamed (@zl23abdessamed).</description>
    <link>https://dev.to/zl23abdessamed</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3313448%2F96499e2a-fd3a-4178-b142-b9d17a7491c0.png</url>
      <title>DEV Community: Zalla Abdessamed</title>
      <link>https://dev.to/zl23abdessamed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zl23abdessamed"/>
    <language>en</language>
    <item>
      <title>Introducing BlazorThemes –Theme Management for Blazor Apps</title>
      <dc:creator>Zalla Abdessamed</dc:creator>
      <pubDate>Thu, 03 Jul 2025 22:09:44 +0000</pubDate>
      <link>https://dev.to/zl23abdessamed/introducing-blazorthemes-theme-management-for-blazor-apps-3d9p</link>
      <guid>https://dev.to/zl23abdessamed/introducing-blazorthemes-theme-management-for-blazor-apps-3d9p</guid>
      <description>&lt;p&gt;Hey folks! After struggling with clean theme switching in multiple Blazor projects, I built a library to solve it once and for all. It’s called BlazorThemes and it’s now at v1.0.1!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Auto dark/light mode that follows OS preferences&lt;/li&gt;
&lt;li&gt;Time-based scheduling for automatic theme switching&lt;/li&gt;
&lt;li&gt;Custom themes with CSS variables&lt;/li&gt;
&lt;li&gt;Cross-tab synchronization&lt;/li&gt;
&lt;li&gt;Zero flash on load&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How To Use:&lt;/strong&gt;&lt;br&gt;
install the package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet add package BlazorThemes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;register the service in the Program.cs file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;builder.Services.AddBlazorThemes(options =&amp;gt; {
    options.Themes = new[] { "light", "dark", "auto" };
    options.EnableSystem = true;
    options.TransitionType = "fade";
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or simply for default use case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;builder.Services.AddBlazorThemes();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add Theme Provider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;BlazorThemesProvider&amp;gt;
    &amp;lt;Router AppAssembly="@typeof(App).Assembly"&amp;gt;
        &amp;lt;!-- Your app content --&amp;gt;
    &amp;lt;/Router&amp;gt;
&amp;lt;/BlazorThemesProvider&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;set the theme easily :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="theme-controls"&amp;gt;
    &amp;lt;button @onclick='() =&amp;gt; ThemesService.SetThemeAsync("light")' 
            class="btn btn-light"&amp;gt;
        ☀️ Light
    &amp;lt;/button&amp;gt;

    &amp;lt;button @onclick='() =&amp;gt; ThemesService.SetThemeAsync("dark")' 
            class="btn btn-dark"&amp;gt;
        🌙 Dark
    &amp;lt;/button&amp;gt;

    &amp;lt;button @onclick='() =&amp;gt; ThemesService.SetThemeAsync("auto")' 
            class="btn btn-auto"&amp;gt;
        🔄 Auto
    &amp;lt;/button&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and you can style your component like this way :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Theme-specific variables */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --text-primary: #1e293b;
    --accent-primary: #3b82f6;
    /* ...other variables */
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f1f5f9;
    --accent-primary: #60a5fa;
    /* ...other variables */
}

/* Component styling using variables */
.component {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.button {
    background-color: var(--accent-primary);
    color: var(--text-on-accent);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Check it out for more features:&lt;/strong&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/Zl23Abdessamed/BlazorThemes" rel="noopener noreferrer"&gt;BlazorThemes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NuGet: &lt;a href="https://www.nuget.org/packages/BlazorThemes" rel="noopener noreferrer"&gt;BlazorThemes Package&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is Version 1.0.1, and I’d love it if you gave it a spin. Bug reports, feature ideas, or any suggestions are more than welcome. I'm open to feedback, collaborations, or anything that helps improve it!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>blazor</category>
      <category>dotnet</category>
      <category>csharp</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
