Skip to content

Solid

No framework-specific package needed. The core API works directly with Solid.

Terminal window
pnpm add typewritingclass
pnpm add -D typewritingclass-compiler
vite.config.ts
import { defineConfig } from 'vite'
import solid from 'vite-plugin-solid'
import twcPlugin from 'typewritingclass-compiler'
export default defineConfig({
plugins: [twcPlugin(), solid()],
})
src/index.tsx
import 'typewritingclass/preflight.css' // optional CSS reset

The compiler replaces tw chains with class name strings at build time — no runtime overhead:

import { tw } from 'typewritingclass'
function Card(props: { children: any }) {
return <div class={tw.p(6).bg.blue500.textColor.white.rounded.lg.hover(tw.bg.blue600)}>{props.children}</div>
}

Use dcx() with a derived signal:

import { createSignal } from 'solid-js'
import { dcx, p, bg, rounded, dynamic } from 'typewritingclass'
function ColorPicker() {
const [color, setColor] = createSignal('#3b82f6')
const result = () => dcx(p(6), bg(dynamic(color())), rounded.lg)
return (
<div>
<input type="color" value={color()} onInput={(e) => setColor(e.currentTarget.value)} />
<div class={result().className} style={result().style}>Preview</div>
</div>
)
}