-
-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[V3] Setting iconActiveBase or controlActive styles for Switch component do not work as expected #3111
Comments
Just noticed there was a new release for skeleton-svelte, just upgraded to 1.0.0-next.17 but the problem stills there. |
@PaoloTorregroza first thing first, make sure to take caution when replacing We cover the use of each type of prop here if it helps: Can you verify the Lightswitch example displays as expected with the Mono theme on our documentation: |
Hi @endigo9740 yes, the switch works well with the mona theme on the docs webpage. And thanks for the advice, I was just messing around with al the possible options to see if I was able to found why the styles where not changing when switching the theme. I forgot to mention im using Firefox. Im trying skeleton v3 on a personal project, this one https://github.com/PaoloTorregroza/Libreedu/, maybe you will be able to replicate it by running it? |
@PaoloTorregroza it's late for me, so I'm just stepping away for the day. But I'll put this on my list to review tomorrow. I should be able to take a look and see what's up. Thanks for sharing the repo itself, that'll help a lot! |
No problem, I really like skeleton, and just migrated to V3, will be reporting everything weird I find! |
Hey @PaoloTorregroza so I've had a chance to review this. I think part of the issue is on either side here, yours and ours. First up, this will be easier to explain with a visual diagram. Here's what the structure of the markup looks like for the component. We'll focus on the GREEN parts here as those are what's visible. In your code snippet, you're modifying the Control and the Icon.
For either, you're setting the styles for a specific state, such as Active/Inactive. Which means a color will be applied in those states. However, I don't think you're taking into account light and dark mode. We provide some documentation covering how this works here: Without the presence of a Additionally, you're using styles such as On our side - we're unfortunately lacking diagrams like I've shown above to help visualize where in the template each style props is being used, which means some of this information is obscured from end users. But are looking to improve this soon. Until then, the best source of truth will be the component Source Code. Which you can find by tapping the small "Svelte" button at the top of each component page. To finish up here, I'd typically provide an example of code that implement the desired visual changes. However, it's occurred to me I don't know what you were aiming for. If you can provide a mock or talk me through what you were going for, I can provide a code snippet in return. Thanks. |
One more quick suggestion here. If I've overwhelmed you with info above, consider doing this. It's a nice little trick:
Something like this: <Switch
name="mode"
controlInactive="bg-green-500"
checked={uiModeHandler.uiMode === 'dark'}
onCheckedChange={handleModeChange}
>
{#snippet inactiveChild()}<IconSun size="14" />{/snippet}
{#snippet activeChild()}<IconMoon size="14" />{/snippet}
</Switch> With this in place, you'll see only the Control's inactive state is affected in base/light mode. For dark mode you could do: <Switch
name="mode"
controlInactive="dark:bg-pink-500"
checked={uiModeHandler.uiMode === 'dark'}
onCheckedChange={handleModeChange}
>
{#snippet inactiveChild()}<IconSun size="14" />{/snippet}
{#snippet activeChild()}<IconMoon size="14" />{/snippet}
</Switch> Then you'll see pink in dark mode. Then combine both to come up with something like this: <Switch
name="mode"
controlInactive="bg-green-500 dark:bg-pink-500"
checked={uiModeHandler.uiMode === 'dark'}
onCheckedChange={handleModeChange}
>
{#snippet inactiveChild()}<IconSun size="14" />{/snippet}
{#snippet activeChild()}<IconMoon size="14" />{/snippet}
</Switch> Finally replace with the desired colors. |
Thanks for the explanation very useful! Im aiming to achieve what the LightSwitch component did on V2, if the dark mode is enabled the switch will have a white icon inside a dark circle on top of a darker background. Im trying to achieve exactly what it is in the documentation, but having the dark mode as the active state. |
@PaoloTorregroza so this will get you in the ballpark. Note I've used Presets here for convenience. <Switch
name="mode"
controlActive="bg-surface-200"
thumbInactive="preset-filled-surface-950-50"
thumbActive="preset-filled-surface-950-50"
bind:checked={mode}
onCheckedChange={handleModeChange}
>
{#snippet inactiveChild()}<IconMoon size="14" />{/snippet}
{#snippet activeChild()}<IconSun size="14" />{/snippet}
</Switch> Here is is in the Cerberus theme, but should be close in Mona. |
Thanks, it is working great, I appreciate the explanation! I think I found an actual bug with the Avatar component but that might be worth discussing on another issue. edit: Nvm, just playing around with what you just showed me I found it was a me problem |
Glad to hear that worked out Paolo. We'll go ahead and mark this complete in that case. |
Current Behavior
Expected Behavior
Setting controlActive does not have the desired effect, I tried changing iconActiveBase as well but it did not worked, when checking the component the colors of it do not change.
Steps To Reproduce
Im using Svelte 5 with sveltekit using skeleton 3.0.0-next.10 and skeleton-svelte 1.0.0-next.16
This is how my code looks right now and its output
If I only use the code in the documentation for a light switch (https://next.skeleton.dev/docs/components/switch/svelte/) it looks like this:


The name of the theme Im using is "mona" but I had this problem with other themes as well.
Link to Reproduction / Stackblitz
No response
More Information
No response
The text was updated successfully, but these errors were encountered: