Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshmossas/tailwind-to-dart
https://github.com/joshmossas/tailwind-to-dart
codegen dart flutter tailwind tailwindcss
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/joshmossas/tailwind-to-dart
- Owner: joshmossas
- Created: 2024-02-09T01:15:10.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-06-30T11:54:47.000Z (4 months ago)
- Last Synced: 2024-10-03T23:47:03.754Z (about 1 month ago)
- Topics: codegen, dart, flutter, tailwind, tailwindcss
- Language: Dart
- Homepage:
- Size: 477 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tailwind to Dart
This library transforms a [Tailwind](https://tailwindcss.com/) config into dart code that you can use in your Flutter apps. This allow you to reuse the same colors, spacing, and font sizes without having to duplicate code.
**Supported Tailwind properties**:
- Colors
- Spacing
- Font Sizes
- Line Heights
- Letter Spacing
- Border Radius
- Border Width
- Opacity**Supported value types**
- Hex colors
- RGB colors
- RGBA colors
- numbers
- px
- em
- rem## CLI Usage
```bash
npx tailwind-to-dart --config --output
``````bash
npm i -g tailwind-to-darttailwind-to-dart --config --output
```## Options
| flag | type | description |
| --------- | ------- | ----------------------------------------------------- |
| --config | string | path to your tailwind.config.js |
| --output | string | path to the desired output location |
| --format | boolean | automatically run "dart format" on the generated file |
| --remSize | string | the desired base font-size. (Default is 16) |## Typescript/Javascript Usage
All of the core functionality is exposed as Typescript functions
```ts
import fs from "node:fs";
import {
getResolvedTailwindConfig,
tailwindConfigToDartString,
} from "tailwind-to-dart";async function main() {
const config = await getResolvedTailwindConfig("./tailwind.config.js");
if (!config.success) {
throw new Error("Error loading config");
}
const dartStr = tailwindConfigToDartString(config.data, {
// options
});
fs.writeFileSync("my_dart_file.dart", dartStr);
}main();
```