skeleton: css background dark fails to load custom setting.

Issue: In Dark Mode App Bar changes to lightest bg-surface-100 when changing dark:bg-surface-800 to dark:bg-surface-900. Secondary: Tailwinds arbitrary value syntax doesn’t work in App Bar dark:bg-#[000000]

Snippet in /src/routes/+layout.svelte: <AppBar background="bg-surface-100 dark:bg-surface-900">

Steps to reproduce the issue:

  1. Navigate to https://skeleton.brainandbonesllc.com/ then ensure page is in Dark Mode.
  2. Ctrl + right click Skeleton header App Bar then inspect in the drop down menu.
  3. Modify class of data-testid=“app-bar” from dark:bg-surface-800 to dark:bg-surface-900
  4. App Bar will turn white.

Thanks for making this project; I’ve been enjoying it profusely.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

Well shoot, those are some kind words! I’m thrilled that our humble little project can help you at all. And much respect to the folks in the “back”. I very much appreciate and admire what you do as well.

To be fair I’m still learning Tailwind as well. I really only started using when my partner and I began work on Skeleton ~6 months ago. I’m still learning new tricks and techniques every day. But there’s absolutely some room for improvement in our docs. Every time someone like yourself runs into an issue, that makes us aware of some gaps to fill in. Which then makes the process easier for the next guy, so thanks for your small bit of suffering 😃

With that in mind I’ll spend some time double checking these sections of the docs soon, especially in regards to the light/dark theme settings and Tailwind config. Like I mentioned, I made some updates today that should get us most of the way there. But I’ll use your feedback to refine more.

This is all part of the joy of using a pre-release library on-top of a pre-release framework (SvelteKit). There’s going to be growing pains until we both hit v1.0!

Again, glad to help. If you experience any other issues don’t hesitate to reach out. Likewise I’m on our Discord most of my waking hours, along with a handful of other great contributors. If I can’t answer your question in a timely manner then perhaps one of them can jump in an assist. Thanks again for taking a chance with us though! It’s much appreciated!

Oh and heads up, do be on the lookout for the next update. It includes a lot of polish and new components, but will come with some breaking changes. I hate to do it, but it’s a necessary evil that will make things less painful long term! If you’re curious you can take a peek here:

https://github.com/Brain-Bones/skeleton/issues/194

One final note. It may help to go ahead and use our stylesheet add-ons. These are just a set of canned styles that will take care of the boring stuff like background color, text color, typography, etc for you. You can still override whatever you wish in your own project’s app.postcss (global stylesheet)

https://skeleton.brainandbonesllc.com/guides/styling

Here’s the result with this and a few small tweaks:

Screen Shot 2022-09-13 at 10 10 34 PM

Screen Shot 2022-09-13 at 10 10 44 PM

Here’s the changes:

layout.svelte

  // Theme
  import "../theme.postcss";
  // Skeleton Add-On Stylesheets
  import "@brainandbones/skeleton/styles/tailwind.css";
  import "@brainandbones/skeleton/styles/core.css";
  import "@brainandbones/skeleton/styles/typography.css";
  // OPTIONAL (read our FORMS guide) // import "@brainandbones/skeleton/styles/forms.css";
  // Global Stylesheets
  import "../app.postcss";
  import { AppShell, AppBar, Button } from "@brainandbones/skeleton";

On your logo img tag I added the following:

class="invert dark:invert-0"

Finally I dropped everything in your global stylesheet and replace it with:

html,
body {
  @apply h-screen overflow-hidden;
}

Likewise I commented out the AppShell slots you weren’t yet using, like sidebars, etc.

Hopefully this helps though 😃

@figuerom16 Sorry for the delay, it’s been a busy day!

I just figured out the issue. It’s really two small things in your Tailwind config. Here’s the full change:

const config = {
  darkMode: 'class',
  content: [
    "./src/**/*.{html,js,svelte,ts}",
    "./node_modules/@brainandbones/skeleton/**/*.{html,js,svelte,ts}"
  ],
  theme: {
    extend: {},
  },
  plugins: [require("@brainandbones/skeleton/tailwind.cjs")],
};

module.exports = config;

First, you may want to go ahead an follow Tailwind’s recommendation for handling Dark Mode, adding the darkMode: class. See the instructions here: https://tailwindcss.com/docs/dark-mode

We’ve already got some improvements in place for the documentation in the next release which should make this setting recommendation more obviously. So that’s 100% on us!

Note that if you’re not using the Skeleton Light Switch component you can manually toggle light/dark mode by applying this class to your app.html file > html element:

<html ... class="dark">
  • no class = light mode
  • dark class = dark mode.

The second issue is something I’ll try to make more clear in our docs. It looks like you replaced what was present in the context setting, but what you needed to do was extend it with the line we provide. By doing so all color stuff seems to be working as expected.

Here’s the result with the changes and manually toggling light/dark mode:

Screen Shot 2022-09-13 at 10 05 43 PM

Screen Shot 2022-09-13 at 10 05 55 PM

theme.postcss

:root {
	/* --- Custom Tailwind Theme --- */
	/* primary (purple) */
	--color-primary-50: 250 245 255;
	--color-primary-100: 243 232 255;
	--color-primary-200: 233 213 255;
	--color-primary-300: 216 180 254;
	--color-primary-400: 192 132 252;
	--color-primary-500: 168 85 247;
	--color-primary-600: 147 51 234;
	--color-primary-700: 126 34 206;
	--color-primary-800: 107 33 168;
	--color-primary-900: 88 28 135;
	/* accent (teal) */
	--color-accent-50: 240 253 250;
	--color-accent-100: 204 251 241;
	--color-accent-200: 153 246 228;
	--color-accent-300: 94 234 212;
	--color-accent-400: 45 212 191;
	--color-accent-500: 20 184 166;
	--color-accent-600: 13 148 136;
	--color-accent-700: 15 118 110;
	--color-accent-800: 17 94 89;
	--color-accent-900: 19 78 74;
	/* warning (rose) */
	--color-warning-50: 255 241 242;
	--color-warning-100: 255 228 230;
	--color-warning-200: 254 205 211;
	--color-warning-300: 253 164 175;
	--color-warning-400: 251 113 133;
	--color-warning-500: 244 63 94;
	--color-warning-600: 225 29 72;
	--color-warning-700: 190 18 60;
	--color-warning-800: 159 18 57;
	--color-warning-900: 136 19 55;
	/* surface (gray) */
	--color-surface-50: 249 250 251;
	--color-surface-100: 243 244 246;
	--color-surface-200: 229 231 235;
	--color-surface-300: 209 213 219;
	--color-surface-400: 156 163 175;
	--color-surface-500: 107 114 128;
	--color-surface-600: 75 85 99;
	--color-surface-700: 55 65 81;
	--color-surface-800: 31 41 55;
	--color-surface-900: 0 0 0;
}