Tailwind CSS

Skeleton features tight integration with Tailwind CSS. Let's install Tailwind and configure all required settings.

The CLI will automatically run the required steps to configure Tailwind for your SvelteKit project.

Configure Tailwind

The following settings must be applied to your tailwind.config.cjs. This file can be found in the root of your project directory.

Enabled Dark Mode Support

Append the following to enable 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 resolves Skeleton's component styles within your project's node_modules.

javascript
const config = {
	// ...
	content: [
		// NOTE: keep this line:
		'./src/**/*.{html,js,svelte,ts}',
		// Append the following for Skeleton:
		require('path').join(require.resolve('@skeletonlabs/skeleton'), '../**/*.{html,js,svelte,ts}')
	],
	// ...
}

Add the Skeleton Plugin

Add the Skeleton plugin. This will ensure Tailwind can generate the appropriate color and design token classes for your project.

javascript
const config = {
	// ...
	plugins: [
		// Keep any existing plugins present and append the following:
		...require('@skeletonlabs/skeleton/tailwind/skeleton.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 Plugin

Typography

Typographic defaults for HTML you don't control.

View Plugin

Line Clamp

Provides utilities for visually truncating text.

View Plugin

Next, review our options for implementing Skeleton themes.

Themes →