Tailwind CSS

Skeleton features tight integration with Tailwind CSS. Let's install Tailwind and set a few configuration settings.

Svelte-Add makes installation a trivial process.

console
npx svelte-add@latest tailwindcss
npm install

Configure Tailwind

Let's modify a few settings in tailwind.config.cjs. This is usually located in the root of your project directory.

Enabled Dark Mode Support

Append darkMode: class to support Tailwind's dark mode. You can pair this with the lightswitch utility to toggle light/dark modes.

javascript
module.exports = {
	darkMode: 'class',
    // ...
}

Update Content Settings

Add the following to the content settings. This ensures the Tailwind compiler sees utility classes for components within node_modules.

javascript
module.exports = {
	// ...
    content: [
        // Keep any existing values present and append the following:
        "./node_modules/@brainandbones/skeleton/**/*.{html,js,svelte,ts}"
    ],
    // ...
}

Add the Skeleton Plugin

Add the Skeleton plugin. This will automatically ingest and utilize the CSS variables defined in your theme. We'll setup the theme in the next step.

javascript
module.exports = {
    // ...
    plugins: [
        // Keep any existing plugins present and append the following:
        require("@brainandbones/skeleton/tailwind/theme.cjs")
    ]
}

Tailwind Plugins

Skeleton pairs well with all of the official Tailwind plugins. These are completely optional though.

Forms

Provides a basic reset for form elements.

View

Typography

Typographic defaults for HTML you don't control.

View

Aspect Ratio

Composable aspect ratios. See compatability.

View

Line Clamp

Provides utilities for visually truncating text.

View

Next, let's create and implement a custom theme.

Create a Theme