diff --git a/examples/demo-app/README.md b/examples/demo-app/README.md
new file mode 100644
index 0000000..114c3a0
--- /dev/null
+++ b/examples/demo-app/README.md
@@ -0,0 +1,114 @@
+# TailwindFX Example Project
+
+This is an example project demonstrating how to use TailwindFX with the Maven plugin for build-time CSS generation.
+
+## Prerequisites
+
+- Java 17 or higher
+- Maven 3.6+
+- TailwindFX installed locally (`mvn install` in the main project)
+
+## Building the Example
+
+```bash
+cd tailwindfx-example
+mvn clean compile
+```
+
+This will:
+1. Scan your Java and FXML files for Tailwind classes
+2. Generate an optimized CSS file at `target/classes/css/tailwindfx-generated.css`
+3. Compile your application
+
+## Running the Example
+
+```bash
+mvn javafx:run
+```
+
+## Project Structure
+
+```
+tailwindfx-example/
+├── pom.xml # Maven configuration with TailwindFX plugin
+├── src/main/java/com/example/
+│ ├── HelloApplication.java # Main application class
+│ └── HelloController.java # FXML controller
+└── src/main/resources/com/example/
+ └── hello-view.fxml # FXML view with Tailwind classes
+```
+
+## Using Tailwind Classes
+
+In Java code:
+```java
+button.getStyleClass().addAll("bg-blue-500", "text-white", "p-4");
+```
+
+In FXML:
+```xml
+
+```
+
+## Plugin Configuration
+
+The Maven plugin is configured in `pom.xml`:
+
+```xml
+
+ io.github.yasmramos.tailwindfx
+ tailwindfx-maven-plugin
+ 1.0-SNAPSHOT
+
+
+
+ generate
+
+
+ true
+ true
+ false
+
+
+
+
+```
+
+### Configuration Options
+
+| Option | Default | Description |
+|--------|---------|-------------|
+| `includeBase` | `true` | Include CSS variables and reset |
+| `includeColors` | `true` | Include color palette |
+| `minify` | `false` | Minify generated CSS |
+| `outputDirectory` | `${project.build.outputDirectory}/css` | Output directory |
+| `outputFileName` | `tailwindfx-generated.css` | Output file name |
+
+## Generated CSS
+
+After running `mvn compile`, check the generated CSS at:
+```
+target/classes/css/tailwindfx-generated.css
+```
+
+This file contains only the Tailwind classes used in your project, resulting in a smaller bundle size.
+
+## Next Steps
+
+1. Add more Tailwind classes to your FXML/Java files
+2. Re-run `mvn compile` to regenerate CSS
+3. Run with `mvn javafx:run` to see the changes
+
+## Troubleshooting
+
+**Plugin not found:** Make sure you've installed TailwindFX locally first:
+```bash
+cd ..
+mvn clean install
+```
+
+**Classes not detected:** Ensure you're using the correct syntax:
+- Java: `getStyleClass().addAll("class1", "class2")` or string literals
+- FXML: `styleClass="class1, class2"`
+
+**CSS not applied:** Check that `TailwindFX.install()` is called in your Application class.
diff --git a/examples/demo-app/pom.xml b/examples/demo-app/pom.xml
new file mode 100644
index 0000000..59352d0
--- /dev/null
+++ b/examples/demo-app/pom.xml
@@ -0,0 +1,87 @@
+
+
+ 4.0.0
+
+ io.github.yasmramos
+ demo-app
+ 1.0-SNAPSHOT
+ jar
+
+ TailwindFX Example
+ Example project demonstrating TailwindFX with Maven plugin
+
+
+ 17
+ UTF-8
+ 17.0.2
+ 1.0-SNAPSHOT
+
+
+
+
+
+ org.openjfx
+ javafx-controls
+ ${javafx.version}
+
+
+ org.openjfx
+ javafx-fxml
+ ${javafx.version}
+
+
+
+
+ io.github.yasmramos
+ tailwindfx
+ ${tailwindfx.version}
+
+
+
+
+
+
+
+ io.github.yasmramos
+ tailwindfx-maven-plugin
+ ${tailwindfx.version}
+
+
+
+ generate
+
+
+ true
+ true
+ false
+ ${project.build.outputDirectory}/css
+ tailwindfx-generated.css
+
+
+
+
+
+
+
+ org.openjfx
+ javafx-maven-plugin
+ 0.0.8
+
+ com.example.HelloApplication
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.11.0
+
+ 17
+
+
+
+
+
diff --git a/examples/demo-app/src/main/java/com/example/HelloApplication.java b/examples/demo-app/src/main/java/com/example/HelloApplication.java
new file mode 100644
index 0000000..a60c28b
--- /dev/null
+++ b/examples/demo-app/src/main/java/com/example/HelloApplication.java
@@ -0,0 +1,26 @@
+package com.example;
+
+import io.github.yasmramos.tailwindfx.TailwindFX;
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+public class HelloApplication extends Application {
+ @Override
+ public void start(Stage stage) throws Exception {
+ FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
+ Scene scene = new Scene(fxmlLoader.load());
+
+ // Initialize TailwindFX with the scene
+ TailwindFX.install(scene);
+
+ stage.setTitle("TailwindFX Example");
+ stage.setScene(scene);
+ stage.show();
+ }
+
+ public static void main(String[] args) {
+ launch();
+ }
+}
diff --git a/examples/demo-app/src/main/java/com/example/HelloController.java b/examples/demo-app/src/main/java/com/example/HelloController.java
new file mode 100644
index 0000000..a891ea1
--- /dev/null
+++ b/examples/demo-app/src/main/java/com/example/HelloController.java
@@ -0,0 +1,14 @@
+package com.example;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.Label;
+
+public class HelloController {
+ @FXML
+ private Label welcomeText;
+
+ @FXML
+ protected void onHelloButtonClick() {
+ welcomeText.setText("Welcome to JavaFX Application!");
+ }
+}
diff --git a/examples/demo-app/src/main/resources/com/example/hello-view.fxml b/examples/demo-app/src/main/resources/com/example/hello-view.fxml
new file mode 100644
index 0000000..598fe2f
--- /dev/null
+++ b/examples/demo-app/src/main/resources/com/example/hello-view.fxml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/io/github/yasmramos/tailwindfx/TwInstall.java b/src/main/java/io/github/yasmramos/tailwindfx/TwInstall.java
index b48b712..2361486 100644
--- a/src/main/java/io/github/yasmramos/tailwindfx/TwInstall.java
+++ b/src/main/java/io/github/yasmramos/tailwindfx/TwInstall.java
@@ -71,14 +71,15 @@ private static void installGeneratedBaseCss(Scene scene, int priority) {
String generatedCss = generator.generateBaseCss();
// Properly encode CSS for data URL (RFC 2397)
- String encodedCss = java.net.URLEncoder.encode(generatedCss, java.nio.charset.StandardCharsets.UTF_8)
- .replace("+", "%20")
- .replace("%3A", ":")
- .replace("%3B", ";")
- .replace("%7B", "{")
- .replace("%7D", "}")
- .replace("%23", "#");
-
+ String encodedCss =
+ java.net.URLEncoder.encode(generatedCss, java.nio.charset.StandardCharsets.UTF_8)
+ .replace("+", "%20")
+ .replace("%3A", ":")
+ .replace("%3B", ";")
+ .replace("%7B", "{")
+ .replace("%7D", "}")
+ .replace("%23", "#");
+
String dataUrl = "data:text/css;charset=utf-8," + encodedCss;
var sheets = scene.getStylesheets();
diff --git a/src/main/java/io/github/yasmramos/tailwindfx/core/ThemeCssGenerator.java b/src/main/java/io/github/yasmramos/tailwindfx/core/ThemeCssGenerator.java
index a38e30e..74ebf61 100644
--- a/src/main/java/io/github/yasmramos/tailwindfx/core/ThemeCssGenerator.java
+++ b/src/main/java/io/github/yasmramos/tailwindfx/core/ThemeCssGenerator.java
@@ -39,20 +39,24 @@ public String generateBaseCss() {
generateShadowVariables(css);
css.append("}\n");
-
+
// Validate CSS structure
String result = css.toString();
if (!result.trim().endsWith("}")) {
throw new IllegalStateException("Generated CSS does not end with closing brace");
}
-
+
long openBraces = result.chars().filter(ch -> ch == '{').count();
long closeBraces = result.chars().filter(ch -> ch == '}').count();
if (openBraces != closeBraces) {
throw new IllegalStateException(
- "CSS brace mismatch: " + openBraces + " opening braces, " + closeBraces + " closing braces");
+ "CSS brace mismatch: "
+ + openBraces
+ + " opening braces, "
+ + closeBraces
+ + " closing braces");
}
-
+
return result;
}
diff --git a/tailwindfx-maven-plugin/pom.xml b/tailwindfx-maven-plugin/pom.xml
index 7c81f90..1fa7b1b 100644
--- a/tailwindfx-maven-plugin/pom.xml
+++ b/tailwindfx-maven-plugin/pom.xml
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- io.github.yasmramos.tailwindfx
+ io.github.yasmramos
tailwindfx-maven-plugin
1.0-SNAPSHOT
maven-plugin