A modern, efficient CSS framework tailored for SvelteKit.
Semantic. Customizable. Lightweight (with PurgeCSS).
.m:p-m).Run these commands:
npm install kf-css
npx kf-css
npm install: Downloads the framework.npx kf-css: Scaffolds src/lib/kf-css and automatically updates vite.config.js.Note: If
vite.config.jsis missing, it will be automatically created with the default configuration:import { defineConfig } from 'vite'; import { kfCss } from 'kf-css'; export default defineConfig({ plugins: [kfCss()], });
Add this single line to the top of your src/routes/+layout.svelte (or specific layout group):
import 'virtual:kf-css';
Start your server:
npm run dev
The plugin compiles your src/lib/kf-css settings into CSS once when the server starts.
Note: If you change your Sass configuration (colors, spacing, etc.), you must restart the server to see the changes.
When you deploy:
npm run build
The plugin automatically generates the final CSS files.
To remove unused CSS (highly recommended for production):
Install: npm install -D @fullhuman/postcss-purgecss
Config: Create postcss.config.cjs in your project root:
const purgecss = require('@fullhuman/postcss-purgecss')({
content: ['./src/**/*.{html,js,svelte,ts}'],
defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
});
module.exports = {
plugins: [...(process.env.NODE_ENV === 'production' ? [purgecss] : [])],
};
If you need to build the CSS manually (e.g. for deployment inspection), you can run:
npx kf-css build
This generates dist/kf.css and dist/kf-responsive.css in your library folder.
The framework is configured via Sass variables in src/config/.
config/colors.scss to define your palette.config/typography.scss for font stacks and scales.config/layout.scss.The plugin/builder.js logic reads your CSS variables (specifically --breakpoint-*) to generate responsive classes.
Added native max-width and max-height utilities:
max-w-s, max-w-m, max-w-l, max-w-xl, max-w-full.max-h-full, max-h-screen.We now support hover:, focus:, and active: prefixes for colors, shadows, and opacity!
Control row and column gaps independently:
gap-x-* (e.g. gap-x-m)gap-y-* (e.g. gap-y-s)Target specific corners:
radius-tl-* (Top Left)radius-tr-* (Top Right)radius-bl-* (Bottom Left)radius-br-* (Bottom Right)Individual transform properties:
scale-90, scale-105, scale-150rotate-45, rotate-90, rotate-180translate-x-full, translate-y-halfMIT