> Markdown version of [Packaging a Theme](https://vaadin.com/docs/v23/styling/custom-theme/custom-theme-packaging). Section index: [llms.txt](https://vaadin.com/docs/v23/styling/llms.txt)

# Packaging a Theme for Reuse

[Example project in GitHub](https://github.com/vaadin/custom-theme-demo/tree/main/reusable-theme)

A custom theme can be packaged into a JAR file for use in multiple applications as follows:

1. Create a new Maven project with the following structure and add your theme files to the theme folder (1):

   ```
   [project root]
   ├── src
   │   └── main
   │       └── resources
   │           └── META-INF
   │               └── resources
   │                   └── themes
   │                       └── my-theme  (1)
   └── pom.xml
   ```

2. Update `pom.xml` as follows:

   - Add the Vaadin version property:

     `pom.xml`

     ```xml
     <vaadin.version>23.6.19</vaadin.version>
     ```

   - Add dependency management:

     ```xml
     <dependencyManagement>
       <dependencies>
         <dependency>
           <groupId>com.vaadin</groupId>
           <artifactId>vaadin-bom</artifactId>
           <version>${vaadin.version}</version>
           <type>pom</type>
           <scope>import</scope>
         </dependency>
       </dependencies>
     </dependencyManagement>
     ```

   - Update dependencies to only contain the following:

     ```xml
     <dependency>
       <groupId>com.vaadin</groupId>
       <artifactId>vaadin</artifactId>
       <scope>provided</scope>
     </dependency>
     ```

3. If the theme uses npm assets, as described in [Style Sheets From npm Packages](https://vaadin.com/docs/v23/styling/custom-theme/custom-theme-configuration.md#stylesheets), add a `Dependencies.java` class (1) with the corresponding `@NpmPackage` annotations:

   ```
   [project root]
   └── src
       └── main
           └── java
               └── com
                   └── vaadin
                       └── flow
                           └── theme
                               └── Dependencies.java  (1)
   ```

   > **Note: Dependency class package**
   >
   > The package in which the java class is placed doesn’t have to be `com.vaadin.flow.theme` package as in the example above, but it’s recommended for themes that are going to be used in Vaadin Spring Boot applications, as it’s always automatically scanned. Other recommended packages are `com.vaadin.flow.component` and `com.vaadin.shrinkwrap`. See Vaadin’s [Spring package scanning documentation](https://vaadin.com/docs/v23/integrations/spring/configuration.md#special-configuration-parameters) for using other custom packages.

4. Create the JAR with `mvn install`.

To use the packaged theme in an application, add the JAR as a dependency and apply the theme using the @Theme annotation.

`07E7BB76-06D2-467F-92B6-A693B057E486`
