Skip to content

Conversation

@boukenka
Copy link
Contributor

@boukenka boukenka commented Mar 22, 2025

Description

In a dark theme, with a MudSwitch with no defined Color, the horizontal bar is not visible.

How Has This Been Tested?

This has only been tested visually. Only one css properties have been modified.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Example

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added enhancement Request for adding a new feature or enhancing existing functionality (not fixing a defect) PR: needs review labels Mar 22, 2025
@Anu6is
Copy link
Contributor

Anu6is commented Mar 22, 2025

How does using dark lighten look. Light mode feels a little too light with this change imo.

Any thoughts on this @danielchalmers

@boukenka
Copy link
Contributor Author

This PR could be connected to Highlighted elements in dark mode using Color.Dark should have a slightly lighter color created by @Yomodo.

@boukenka
Copy link
Contributor Author

boukenka commented Mar 22, 2025

How does using dark lighten look. Light mode feels a little too light with this change imo.

Smh thoughts on this @danielchalmers

@Anu6is Voilà! With --mud-palette-dark-lighten.

image

@Anu6is
Copy link
Contributor

Anu6is commented Mar 22, 2025

Hmmmm, not great. Thanks for checking

@boukenka
Copy link
Contributor Author

I have also tried --mud-palette-gray-light, --mud-palette-gray-lighter and --mud-palette-gray-darker. None of them were Ok.

@boukenka
Copy link
Contributor Author

boukenka commented Mar 22, 2025

I have updated the PR. background-color uses Colors.Gray.Darken1 aka var(--mud-palette-gray-dark). opacity modification only applies when the MudSwitch is disabled.

image

with the CSS modifications below.

image

Is it better than the current PR proposal?

@Anu6is
Copy link
Contributor

Anu6is commented Mar 22, 2025

Yeah, I think I prefer this one.

@boukenka
Copy link
Contributor Author

boukenka commented Mar 22, 2025

Yeah, I think I prefer this one.

Thanks for the feedback. I have updated the PR with this new proposal.

@codecov
Copy link

codecov bot commented Mar 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.06%. Comparing base (68a2118) to head (1492c50).
Report is 8 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #11077   +/-   ##
=======================================
  Coverage   91.05%   91.06%           
=======================================
  Files         429      429           
  Lines       13965    13999   +34     
  Branches     2698     2706    +8     
=======================================
+ Hits        12716    12748   +32     
  Misses        646      646           
- Partials      603      605    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Garderoben
Copy link
Member

Garderoben commented Mar 24, 2025

Ýour screenshots are from docs, please note that docs and mudblazor itself have different dark themes.
Also note that the trackitself has both color and opacity here.

I dont know why the switch is using black here, was it changed? pretty sure it should use one of the action colors, example:
--mud-palette-action-default

@boukenka
Copy link
Contributor Author

boukenka commented Mar 24, 2025

Ýour screenshots are from docs, please note that docs and mudblazor itself have different dark themes. Also note that the trackitself has both color and opacity here.

With a default Blazor Web App and not from the docs.

image

<div class="d-flex">
    <MudSwitch @bind-Value="Basic_Switch1" />
    <MudSwitch @bind-Value="Basic_Switch2" Color="Color.Primary" />
    <MudSwitch @bind-Value="Basic_Switch3" Color="Color.Secondary" />
    <MudSwitch T="bool" Disabled="true" />
</div>
<div class="d-flex mt-2">
    <MudSwitch @bind-Value="Basic_Switch4" Color="Color.Success" UncheckedColor="Color.Error" />
    <MudSwitch @bind-Value="Basic_Switch5" Color="Color.Primary" UncheckedColor="Color.Secondary" />
    <MudSwitch @bind-Value="Basic_Switch6" Color="Color.Info" UncheckedColor="Color.Warning" />
    <MudSwitch T="bool" Disabled="true" UncheckedColor="Color.Default" />
</div>

@code {
    public bool Basic_Switch1 { get; set; } = false;
    public bool Basic_Switch2 { get; set; } = true;
    public bool Basic_Switch3 { get; set; } = true;
    public bool Basic_Switch4 { get; set; } = false;
    public bool Basic_Switch5 { get; set; } = true;
    public bool Basic_Switch6 { get; set; } = true;
}

@boukenka
Copy link
Contributor Author

I dont know why the switch is using black here, was it changed? pretty sure it should use one of the action colors, example: --mud-palette-action-default

Today, below is the current definition for mud-switch-track.

image

@boukenka
Copy link
Contributor Author

B) Here is the result with background-color: var(--mud-palette-action-default); and opacity: 0.4 !important;

image

C) Here is the result with background-color: var(--mud-palette-action-default); and opacity: 0.12 !important; (original value).

image

@Garderoben What do you think? Which solution do you prefer ? The PR, B or C? Or none of them ?

@Garderoben
Copy link
Member

B) Here is the result with background-color: var(--mud-palette-action-default); and opacity: 0.4 !important;

image

C) Here is the result with background-color: var(--mud-palette-action-default); and opacity: 0.12 !important; (original value).

image

@Garderoben What do you think? Which solution do you prefer ? The PR, B or C? Or none of them ?

Now its looking way better! i vote for C @danielchalmers what about you?

@Garderoben Garderoben self-requested a review March 25, 2025 14:37
@Anu6is
Copy link
Contributor

Anu6is commented Mar 25, 2025

I agree with C as well.

@boukenka
Copy link
Contributor Author

boukenka commented Mar 25, 2025

Thank you for your feedback. PR updated with C solution. Ready to update if @danielchalmers has a different opinion.

@sonarqubecloud
Copy link

Copy link
Member

@danielchalmers danielchalmers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great on both light and dark + more consistent with other inputs

@danielchalmers danielchalmers changed the title MudSwitch Default Background Color MudSwitch: Change track color to improve visibility on dark theme Mar 30, 2025
@danielchalmers danielchalmers merged commit abfc821 into MudBlazor:dev Mar 30, 2025
6 checks passed
@danielchalmers
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for adding a new feature or enhancing existing functionality (not fixing a defect)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants