Tailwind CSS

Skeleton features tight integration with Tailwind CSS. Let's install Tailwind and configure required 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
const config = {
	darkMode: 'class',
    // ...
}

Update Content Settings

Add the following to the content settings. This will ensure the Tailwind compiler can locate utility classes for Skeleton features within node_modules.

javascript
const config = {
	// ...
    content: [
        // Keep existing values and append the following:
        require('path').join(require.resolve('@brainandbones/skeleton'), '../**/*.{html,js,svelte,ts}')
    ],
    // ...
}

Add the Skeleton Plugin

Add the Skeleton plugin. This will ensure Tailwind can generate color classes based on your theme. We'll setup our theme in the following step.

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

Tailwind Plugins

Optional

Skeleton pairs well with all of the official Tailwind plugins. These are optional and should only be added if your project requires them.

Forms

Provides a basic reset for form elements.

View

Typography

Typographic defaults for HTML you don't control.

View

Aspect Ratio

Note this plugin requires a compatibility configuration.

View

Line Clamp

Provides utilities for visually truncating text.

View

Next, let's implement a Skeleton theme.

Themes →