{"id":44359751,"url":"https://github.com/akzhy/flairjs","last_synced_at":"2026-02-15T18:04:55.295Z","repository":{"id":318521297,"uuid":"969027611","full_name":"akzhy/flairjs","owner":"akzhy","description":"A rust powered build time CSS / Style tag in JSX library","archived":false,"fork":false,"pushed_at":"2026-02-11T17:37:24.000Z","size":2579,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-12T00:34:06.472Z","etag":null,"topics":["css","jsx","rust","style"],"latest_commit_sha":null,"homepage":"https://flair.akzhy.com/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akzhy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-19T08:07:12.000Z","updated_at":"2026-01-28T13:14:41.000Z","dependencies_parsed_at":"2025-10-07T18:35:07.078Z","dependency_job_id":"141271da-4533-4cb0-afb1-6abfc6bb3223","html_url":"https://github.com/akzhy/flairjs","commit_stats":null,"previous_names":["akzhy/flairjs"],"tags_count":121,"template":false,"template_full_name":null,"purl":"pkg:github/akzhy/flairjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akzhy%2Fflairjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akzhy%2Fflairjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akzhy%2Fflairjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akzhy%2Fflairjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akzhy","download_url":"https://codeload.github.com/akzhy/flairjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akzhy%2Fflairjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29486066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T15:33:17.885Z","status":"ssl_error","status_checked_at":"2026-02-15T15:32:53.698Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","jsx","rust","style"],"created_at":"2026-02-11T17:16:46.392Z","updated_at":"2026-02-15T18:04:55.289Z","avatar_url":"https://github.com/akzhy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flair ✨\n\nA build-time CSS-in-JSX solution that brings the power of modern CSS to your React components with zero runtime overhead.\n![Demo](./demo.gif)\n\n\u003eNote: Flair is still in early development. Expect minor bugs and issues. Feedback is welcome!\n\nTry it online on StackBlitz.\n\n\n[React Vite](https://stackblitz.com/edit/flairjs-vite-react?file=src%2FApp.tsx) | [SolidJS Vite](https://stackblitz.com/edit/solidjs-templates-famw2yzx?file=src%2FApp.tsx) | [Preact Vite](https://stackblitz.com/edit/vitejs-vite-zt9k3zr7?file=src%2Fapp.tsx)\n\n## Features\n\n- 🚀 **Zero Runtime** - All CSS processing happens at build time\n- 💅 **Multiple Styling APIs** - Choose between `\u003cStyle\u003e` tags, `flair()` objects, or `css` template literals\n- 🌙 **Theme System** - Built-in theming with TypeScript intellisense\n- 🔧 **Build Tool Integration** - Supports Vite, NextJS, Rollup, Webpack, and Parcel\n- 🎯 **Scoped by Default** - Component-scoped styles with global override option\n- ⚡ **Rust-Powered** - Fast AST parsing with OXC and CSS processing with Lightning CSS\n- 🔍 **Static Analysis** - Class names and CSS are analyzed at build time for optimal performance\n\n## Quick Start\n\n### Installation\n\n```bash\n# Install client package\nnpm install @flairjs/client\n\n# Install your bundler plugin\nnpm install @flairjs/vite-plugin        # For Vite\nnpm install @flairjs/rollup-plugin      # For Rollup\nnpm install @flairjs/webpack-loader     # For Webpack\nnpm install @flairjs/parcel-transformer # For Parcel\n```\n\n### Basic Setup\n\n#### Vite Configuration\n\n```js\n// vite.config.js\nimport { defineConfig } from \"vite\";\nimport react from \"@vitejs/plugin-react\";\nimport flairjs from \"@flairjs/vite-plugin\";\n\nexport default defineConfig({\n  plugins: [react(), flairjs()],\n});\n```\n\n#### Component Usage\n\n```jsx\nimport { flair } from \"@flairjs/client\";\n\nconst Button = () =\u003e {\n  return \u003cbutton className=\"button\"\u003eClick me!\u003c/button\u003e;\n};\n\n// Style with flair object\nButton.flair = flair({\n  \".button\": {\n    backgroundColor: \"blue\",\n    color: \"white\",\n    padding: \"12px 24px\",\n    borderRadius: \"8px\",\n    border: \"none\",\n    \"\u0026:hover\": {\n      backgroundColor: \"darkblue\",\n    },\n  },\n});\n\nexport default Button;\n```\n\n## Styling Methods\n\nFlair provides three ways to write CSS in your components:\n\n### 1. Flair Object API\n\n```jsx\nimport { flair } from \"@flairjs/client\";\n\nconst Card = () =\u003e \u003cdiv className=\"card\"\u003eContent\u003c/div\u003e;\n\nCard.flair = flair({\n  \".card\": {\n    backgroundColor: \"white\",\n    borderRadius: \"8px\",\n    boxShadow: \"0 2px 4px rgba(0,0,0,0.1)\",\n    padding: \"16px\",\n  },\n});\n```\n\n### 2. CSS Template Literals\n\n```jsx\nimport { css } from \"@flairjs/client\";\n\nconst Card = () =\u003e \u003cdiv className=\"card\"\u003eContent\u003c/div\u003e;\n\nCard.flair = css`\n  .card {\n    background-color: white;\n    border-radius: 8px;\n    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n    padding: 16px;\n  }\n`;\n```\n\n### 3. Style Tag Components\n\n```jsx\nimport { Style } from \"@flairjs/client/react\";\n\nconst Card = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cdiv className=\"card\"\u003eContent\u003c/div\u003e\n      \u003cStyle\u003e{`\n        .card {\n          background-color: white;\n          border-radius: 8px;\n          box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n          padding: 16px;\n        }\n      `}\u003c/Style\u003e\n    \u003c/\u003e\n  );\n};\n```\n\n## Global Styles\n\nBy default, styles are scoped to components. You can make styles global:\n\n### With Style Tag\n\n```jsx\nimport { Style } from \"@flairjs/client/react\";\n\nconst App = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStyle global\u003e{`\n        body {\n          margin: 0;\n          font-family: -apple-system, BlinkMacSystemFont, sans-serif;\n        }\n      `}\u003c/Style\u003e\n      {/* Your app content */}\n    \u003c/\u003e\n  );\n};\n```\n\n### With globalFlair Property\n\n```jsx\nconst App = () =\u003e \u003cdiv\u003eApp content\u003c/div\u003e;\n\nApp.globalFlair = css`\n  body {\n    margin: 0;\n    font-family: -apple-system, BlinkMacSystemFont, sans-serif;\n  }\n`;\n```\n\n## Theming\n\n### Setup\n\nTo enable theming support, you need to:\n\n1. **Import the theme CSS** in your top-level file (e.g., `main.tsx`, `App.tsx`, or `index.tsx`):\n\n```jsx\nimport \"@flairjs/client/theme.css\";\n```\n\n2. **Create a theme configuration file** `flair.theme.ts` in your project root:\n\n```typescript\n// flair.theme.ts\nimport { defineConfig } from \"@flairjs/client\";\n\nconst theme = defineConfig({\n  prefix: \"flair\",\n  selector: \"body\",\n  tokens: {\n    colors: {\n      primary: \"#3b82f6\",\n      secondary: \"#64748b\",\n      success: \"#10b981\",\n      danger: \"#ef4444\",\n    },\n    fonts: {\n      family: \"'Inter', sans-serif\",\n      size: {\n        sm: \"14px\",\n        md: \"16px\",\n        lg: \"18px\",\n      },\n    },\n    space: {\n      1: \"4px\",\n      2: \"8px\",\n      3: \"12px\",\n      4: \"16px\",\n      5: \"20px\",\n      6: \"24px\",\n    },\n  },\n  breakpoints: {\n    sm: \"640px\",\n    md: \"768px\",\n    lg: \"1024px\",\n    xl: \"1280px\",\n  },\n});\n\nexport default theme;\nexport type Theme = typeof theme;\n```\n\n### Using Theme Tokens\n\n```jsx\nimport { flair } from \"@flairjs/client\";\n\nconst Button = () =\u003e \u003cbutton className=\"button\"\u003eClick me\u003c/button\u003e;\n\nButton.flair = flair({\n  \".button\": {\n    backgroundColor: \"$colors.primary\",\n    color: \"white\",\n    padding: \"$space.3 $space.5\",\n    fontSize: \"$fonts.size.md\",\n    fontFamily: \"$fonts.family\",\n  },\n});\n```\n\n### TypeScript Intellisense\n\nFor theme token autocomplete, extend the `FlairTheme` interface:\n\n```typescript\n// types/flair.d.ts\nimport { Theme } from \"../flair.theme\";\n\ndeclare module \"@flairjs/client\" {\n  export interface FlairTheme extends Theme {}\n}\n```\n\n### Responsive Design\n\n```jsx\nButton.flair = flair({\n  \".button\": {\n    padding: \"$space.2 $space.3\",\n    fontSize: \"$fonts.size.sm\",\n\n    // Responsive breakpoints\n    \"$screen md\": {\n      padding: \"$space.3 $space.5\",\n      fontSize: \"$fonts.size.md\",\n    },\n\n    \"$screen lg\": {\n      padding: \"$space.4 $space.6\",\n      fontSize: \"$fonts.size.lg\",\n    },\n  },\n});\n```\n\n## Bundler Integration\n\n### Vite\n\n```js\n// vite.config.js\nimport flairjs from \"@flairjs/vite-plugin\";\n\nexport default {\n  plugins: [\n    flairjs({\n      classNameList: [\"className\", \"class\"],\n      // Optional: Include/exclude files\n      include: [\"src/**/*.{tsx,jsx}\"],\n      exclude: [\"node_modules/**\"],\n    }),\n  ],\n};\n```\n\n### Webpack\n\n```js\n// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(tsx|jsx)$/,\n        use: [\"@flairjs/webpack-loader\"],\n      },\n    ],\n  },\n};\n```\n\n### Rollup\n\n```js\n// rollup.config.js\nimport flairjs from \"@flairjs/rollup-plugin\";\n\nexport default {\n  plugins: [\n    // Make sure rollup is configured to handle css imports.\n    // Add flair before any other JSX parsers\n    flairjs(),\n  ],\n};\n```\n\n### Parcel\n\n```json\n// .parcelrc\n{\n  \"extends\": \"@parcel/config-default\",\n  \"transformers\": {\n    \"*.{tsx,jsx}\": [\"@flairjs/parcel-transformer\", \"...\"]\n  }\n}\n```\n\n## Advanced Features\n\n### Static Analysis and Class Name Inference\n\nSince Flair is a **build-time library**, all CSS and class names must be **statically inferrable** at build time. Flair cannot process dynamically generated CSS or class names that are only known at runtime.\n\n#### What Works (Static Analysis)\n\nIn most cases, Flair can infer class names automatically:\n\n```jsx\n// ✅ Direct className\n\u003cbutton className=\"btn\"\u003eClick me\u003c/button\u003e\n\n// ✅ Variable stored className\nconst buttonClass = \"btn btn-primary\"\n\u003cbutton className={buttonClass}\u003eClick me\u003c/button\u003e\n\n// ✅ Function parameters\nconst variant = \"primary\"\n\u003cbutton className={clsx(variant)}\u003eClick me\u003c/button\u003e\n```\n\n#### What Doesn't Work (Dynamic Class Names)\n\n```jsx\n// ❌ Function calls - Flair cannot infer the return value\n\u003cbutton className={someFunction()}\u003eClick me\u003c/button\u003e\n\n// ❌ Complex runtime expressions\n\u003cbutton className={`btn btn-${variant}`}\u003eClick me\u003c/button\u003e\n```\n\n### Class Name Utilities: `c()` and `cn()`\n\nWhen Flair cannot directly infer a class name (e.g., when returned from a function), use the `c()` or `cn()` utilities to signal which class names should be included:\n\n```jsx\nimport { c, cn } from \"@flairjs/client\";\n\n// Both c() and cn() are identical - they simply return what you pass to them\n// Their purpose is to signal to Flair's build-time analyzer which class names to include\n\nfunction getButtonClass() {\n  // ✅ Signal to Flair that 'btn' and 'btn-primary' should be included\n  return c(\"btn btn-primary\");\n}\n\nconst Button = () =\u003e {\n  return \u003cbutton className={getButtonClass()}\u003eClick me\u003c/button\u003e;\n};\n\nButton.flair = flair({\n  \".btn\": { padding: \"12px 24px\" },\n  \".btn-primary\": { backgroundColor: \"blue\" },\n});\n```\n\n**Important Notes:**\n\n- `c()` and `cn()` are **not** like `clsx` or `classnames` - they don't merge or conditionally apply classes\n- They are simple pass-through functions: `c('foo')` just returns `'foo'`\n- Their only purpose is to help Flair's static analyzer find class names in your code\n- At runtime, they have zero overhead (they literally just return their input)\n\n### Nesting and Pseudo-selectors\n\n```jsx\nCard.flair = flair({\n  \".card\": {\n    backgroundColor: \"white\",\n\n    \"\u0026:hover\": {\n      backgroundColor: \"#f9f9f9\",\n    },\n\n    \"\u0026.active\": {\n      borderColor: \"$colors.primary\",\n    },\n\n    \"\u0026 .title\": {\n      fontSize: \"$fonts.size.lg\",\n      fontWeight: \"bold\",\n    },\n  },\n});\n```\n\n### Media Queries\n\n```jsx\nCard.flair = flair({\n  \".card\": {\n    padding: \"$space.3\",\n\n    \"@media (min-width: 768px)\": {\n      padding: \"$space.5\",\n    },\n  },\n});\n```\n\n## Framework Support\n\nCurrently, `flair` property is supported in all JSX frameworks.\nFlair component is supported in:\n\n- ✅ React (via `@flairjs/client/react`)\n- ✅ Preact (via `@flairjs/client/preact`)\n- ✅ SolidJS (via `@flairjs/client/solidjs`)\n\n## Performance\n\n- **Zero Runtime Overhead** - All CSS is extracted at build time\n- **Optimal Bundle Size** - Only the CSS you use is included\n- **Fast Builds** - Rust-powered transformation with OXC and Lightning CSS\n- **Efficient Caching** - Smart caching of transformed components\n\n## Browser Support\n\nFlair generates modern CSS that works in all evergreen browsers. Legacy browser support depends on your build setup and CSS processing pipeline.\n\n## Contributing\n\nWe welcome contributions! Here's how to get started:\n\n### Development Setup\n\n1. **Clone the repository**\n\n   ```bash\n   git clone https://github.com/akzhy/flairjs.git\n   cd flairjs\n   ```\n\n2. **Install dependencies**\n\n   ```bash\n   pnpm install\n   ```\n\n3. **Build packages**\n\n   ```bash\n   # Build all packages\n   pnpm build\n\n   # Or build specific packages\n   pnpm build:core              # Build core Rust package\n   pnpm build:non-core-packages # Build all other packages\n   ```\n\n### Making Changes\n\nWhen contributing changes, please follow these steps:\n\n1. **Create a new branch** for your feature or bugfix\n\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n\n2. **Make your changes** and ensure all packages build successfully\n\n3. **Add a changeset** to document your changes\n\n   ```bash\n   pnpm changeset\n   ```\n\n   This will prompt you to:\n\n   - Select which packages are affected by your changes\n   - Specify the type of change (major, minor, patch)\n   - Write a description of your changes\n\n   The changeset system ensures proper versioning and generates changelogs automatically.\n\n4. **Commit your changes** including the changeset file\n\n   ```bash\n   git add .\n   git commit -m \"a sensible commit message\"\n   ```\n\n5. **Push your branch** and create a pull request\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n\n### Changeset Guidelines\n\n- **Patch** (0.0.x): Bug fixes, documentation updates, internal refactors\n- **Minor** (0.x.0): New features, non-breaking enhancements\n- **Major** (x.0.0): Breaking changes, API changes\n\nExample changeset workflow:\n\n```bash\n# After making changes to @flairjs/vite-plugin\npnpm changeset\n\n# You'll be prompted:\n# - Select @flairjs/vite-plugin\n# - Choose \"patch\" for a bugfix\n# - Describe: \"Fixed issue with theme token resolution\"\n```\n\n### Testing\n\nBefore submitting a PR:\n\n- Ensure all packages build without errors: `pnpm build`\n- Test your changes in the example project: `examples/vite-react-ts`\n- Run any available tests in the affected packages\n\n### Questions?\n\nFeel free to open an issue for any questions or discussions about contributing!\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n## Packages\n\nThis monorepo contains the following packages:\n\n- [`@flairjs/core`](./packages/core) - Core transformation engine (Rust + NAPI)\n- [`@flairjs/client`](./packages/client) - Client-side utilities and types\n- [`@flairjs/bundler-shared`](./packages/shared) - Shared bundler utilities\n- [`@flairjs/vite-plugin`](./packages/vite-plugin) - Vite integration\n- [`@flairjs/rollup-plugin`](./packages/rollup-plugin) - Rollup integration\n- [`@flairjs/webpack-loader`](./packages/webpack-loader) - Webpack integration\n- [`@flairjs/parcel-transformer`](./packages/parcel-transformer) - Parcel integration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakzhy%2Fflairjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakzhy%2Fflairjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakzhy%2Fflairjs/lists"}