Vicinage, type-safe and zero-runtime UI styling, right in the markup.

typescript dev.to

Vicinage ·

Type-safe and zero-runtime UI styling, right in the markup.

Vicinage lets you write strongly-typed CSS objects directly on your markup. At build time, it preprocesses them into StyleX API calls, which StyleX then extracts into zero-runtime atomic CSS, with no style block naming required.

Table of Contents

Quick Start

Setup

Vicinage is implemented as a preprocessor for StyleX.

Install the packages:

npm install vicinage @stylexjs/stylex
npm install --save-dev @vicinage/unplugin @stylexjs/unplugin
Enter fullscreen mode Exit fullscreen mode

Add the plugin to your bundler configuration right before the StyleX plugin.

import { defineConfig } from 'vite'
import vicinage from '@vicinage/unplugin'
import stylex from '@stylexjs/unplugin'

export default defineConfig({
  plugins: [
    vicinage.vite(),
    stylex.vite(),
    // ...other plugins
  ],
})
Enter fullscreen mode Exit fullscreen mode

Source: dev.to

arrow_back Back to Tutorials