Zero-runtime CSS-in-TypeScript framework
92% smaller than Panda β’ 1.6 KB gzipped β’ Zero codegen β’ 15+ frameworks
Website β’ Documentation β’ Examples β’ Discord
Silk is a production-ready CSS-in-TypeScript framework that delivers type-safe styling with zero runtime cost. Built-time CSS extraction, comprehensive framework support, and industry-leading bundle sizes.
Bundle Size Comparison (200 components):
# Core package
bun add @sylphx/silk
# With build plugin (zero-runtime)
bun add @sylphx/silk @sylphx/silk-vite-plugin
# Framework-specific
bun add @sylphx/silk-nextjs # Next.js (Webpack/Turbopack)
bun add @sylphx/silk-react # React (any bundler)
bun add @sylphx/silk-vue # Vue 3
bun add @sylphx/silk-svelte # Svelte/SvelteKit
1. Install:
bun add @sylphx/silk @sylphx/silk-vite-plugin @sylphx/silk-react
2. Configure Vite:
// vite.config.ts
import { defineConfig } from 'vite'
import silk from '@sylphx/silk-vite-plugin'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
silk(), // Add before React
react(),
],
})
3. Create config:
// silk.config.ts
import { defineConfig } from '@sylphx/silk'
import { createSilkReact } from '@sylphx/silk-react'
export const { styled, Box, Flex, Grid, Text, css } = createSilkReact(
defineConfig({
colors: {
brand: { 500: '#3b82f6', 600: '#2563eb' },
gray: { 100: '#f3f4f6', 900: '#111827' }
},
spacing: { 4: '1rem', 8: '2rem' },
fontSizes: { base: '1rem', lg: '1.125rem' }
} as const)
)
4. Use in components:
// App.tsx
import { Box, Text, styled } from './silk.config'
import './silk.css' // Import generated CSS
const Button = styled('button', {
bg: 'brand.500', // β
Autocomplete
color: 'white',
px: 6,
py: 3,
_hover: {
bg: 'brand.600' // β
Type-safe
}
})
function App() {
return (
<Box p={8} bg="gray.100">
<Text fontSize="lg" color="gray.900">
Hello Silk! π¨
</Text>
<Button>Get Started</Button>
</Box>
)
}
Done! CSS extracted at build-time, zero runtime overhead.
15+ frameworks with zero-runtime compilation:
| Framework | Package | Bundle Size |
|---|---|---|
| Next.js | @sylphx/silk-nextjs |
1.6 KB |
| Remix | @sylphx/silk-remix |
1.6 KB |
| Astro | @sylphx/silk-astro |
1.6 KB |
| Vite (React/Vue/Svelte) | @sylphx/silk-vite-plugin |
1.6 KB |
| Solid.js | @sylphx/silk-solid |
1.6 KB |
| Nuxt 3 | @sylphx/silk-nuxt |
1.6 KB |
| Qwik | @sylphx/silk-qwik |
1.6 KB |
| Preact | @sylphx/silk-preact |
1.6 KB |
All integrations maintain the same 1.6 KB gzipped bundle size.
// Your code
import { css } from '@sylphx/silk'
const button = css({ bg: 'blue', px: 4 })
// β Transformed at build-time
const button = "silk_bg_blue_a1b2 silk_px_4_c3d4"
// CSS extracted to silk.css:
.silk_bg_blue_a1b2 { background-color: blue; }
.silk_px_4_c3d4 { padding: 1rem; }
Zero runtime cost:
const config = defineConfig({
colors: { brand: { 500: '#3b82f6' } },
spacing: { 4: '1rem' }
} as const)
// TypeScript automatically infers:
// type ColorToken = 'brand.500'
// type SpacingToken = 4
// β
Valid
css({ color: 'brand.500', p: 4 })
// β Compile error
css({ color: 'purple.500' }) // 'purple' not in config
No codegen required - Template literal types provide autocomplete.
| Components | Silk | Panda CSS | Tailwind | Savings |
|---|---|---|---|---|
| 80 classes | 1.6 KB | 421B | 315B | -74% |
| 600 classes | 1.6 KB | 1.3 KB | 1.1 KB | -19% |
| 3000 classes | 1.6 KB | 5.0 KB | 4.6 KB | +213% |
Silk scales better - Constant 1.6 KB regardless of app size.
getRuntimeStats() for analyticsconst card = css({
containerType: 'inline-size',
'@container (min-width: 400px)': {
flexDirection: 'row'
}
})
const button = css({
'@scope': {
root: '.card',
styles: { color: 'brand.500' }
}
})
const modal = css({
opacity: 1,
'@starting-style': {
opacity: 0 // From display:none
}
})
import { oklch, colorMix, lighten } from '@sylphx/silk'
const blue = oklch(0.7, 0.2, 250) // Perceptually uniform
const accent = colorMix('blue', 'red', 60)
const light = lighten('blue', 20)
| Feature | Silk | Panda CSS |
|---|---|---|
| Bundle Size | 1.6 KB | 5.0 KB (+213%) |
| Codegen | β Zero | β οΈ Required |
| Setup | 1 file | Multiple steps |
| Modern CSS | β Full | β Limited |
| Critical CSS | β Built-in | β None |
| Type Safety | β Perfect | β Good |
| Feature | Silk | Tailwind |
|---|---|---|
| Type Safety | β Compile-time | β None |
| Bundle (Large) | 1.6 KB | 4.6 KB (+187%) |
| Autocomplete | β Native | β οΈ Extension |
| Custom Tokens | β Full control | β οΈ Config |
| Runtime | β Zero | β Zero |
Silk combines the best of both:
Pre-configured design systems for rapid development:
bun add @sylphx/silk-preset-material # ~2 KB
import { materialPreset } from '@sylphx/silk-preset-material'
const { css } = createStyleSystem(materialPreset)
const button = css({
bg: 'primary.40',
fontSize: 'label-large',
shadow: 'level1'
})
bun add @sylphx/silk-preset-minimal # ~1 KB
import { minimalPreset } from '@sylphx/silk-preset-minimal'
const { css } = createStyleSystem(minimalPreset)
Perfect for: Documentation, portfolios, minimal UIs
import { CriticalCSSExtractor } from '@sylphx/silk'
const extractor = new CriticalCSSExtractor()
extractor.autoDetect(css) // Auto-detect critical patterns
const { critical, nonCritical } = extractor.extract(css)
Impact: 30-50% faster first paint
import { ProductionOptimizer } from '@sylphx/silk'
const optimizer = new ProductionOptimizer({
treeShaking: true, // 50-90% reduction
minification: true, // 20-30% reduction
deduplication: true // 10-30% reduction
})
const result = await optimizer.optimize(css)
Total savings: 50-90% smaller bundles
// vite.config.ts
silk({
compression: {
brotli: true, // 15-25% smaller
brotliQuality: 11
}
})
import { getRuntimeStats } from '@sylphx/silk'
const stats = getRuntimeStats()
console.log(stats.memoCache.hitRate) // 85% cache hits
// Define config
const config = defineConfig({
colors: { primary: { 500: '#3b82f6' } },
spacing: { 4: '1rem' }
})
// Create style system
const { css, cx, getCSSRules } = createStyleSystem(config)
// Generate styles
const button = css({ color: 'primary.500', p: 4 })
import { createSilkReact } from '@sylphx/silk-react'
const { styled, Box, Flex, Grid, Text } = createSilkReact(config)
// Styled components
const Button = styled('button', {
bg: 'primary.500',
_hover: { bg: 'primary.600' }
})
// Primitives
<Box p={4}>
<Flex gap={2}>
<Text fontSize="lg">Hello</Text>
</Flex>
</Box>
cd examples/react-demo
bun install && bun dev
Includes:
bun packages/core/src/benchmark.demo.ts
Compare:
# Install dependencies
bun install
# Run tests (494 passing)
bun test
# Run benchmarks
bun test --run benchmark.bench.ts
# Build
bun run build
# Type checking
bun run typecheck
β Completed
π Next
Show Your Support: β Star β’ π Watch β’ π Report bugs β’ π‘ Suggest features β’ π Contribute
MIT Β© Sylphx
Inspired by the best CSS frameworks:
Built with β€οΈ by developers who care about bundle size.
92% smaller. Zero runtime. Zero codegen.
The CSS-in-TypeScript framework that scales
sylphx.com β’
@SylphxAI β’
[email protected]