TW Elements integration with Solid - Free Examples & Tutorial

This article shows you how to integrate Solid application with TW Elements. Free download, open source license.

Prerequisites

Before starting the project make sure to install the following utilities:

  • Node LTS (18.x.x or higher recommended)
  • Code editor. We recommend VSCode

Creating a new Solid application

Let's create a fresh Solid application so that we can go through all the steps together. We are going to do this through Vite - very popular and extremely light module bundler.

Step 1

Create new project.

Step 2

Run the development server.


Installing and configuring Tailwind CSS and TW Elements

Step 1

Install Tailwind CSS.

File structure

If you have followed all instructions mentioned earlier, your file structure should look like this:

      
        my-project/
        ├── node_modules/
        ├── src/
        │   ├── assets/
        │   ├── App.jsx
        │   ├── App.module.css
        │   ├── index.css
        │   ├── index.jsx
        │   └── ...
        ├── ...
        ├── index.html
        ├── jsconfig.json
        ├── package-lock.json
        ├── package.json
        ├── ...
        ├── postcss.config.js
        ├── README.md
        ├── tailwind.config.js
        └── vite.config.js
      
    

Step 2

Add the paths to all of your template files in your tailwind.config.js file.

Step 3

Include the @tailwind directives in your index.css file.

Step 4

Install TW elements.

Step 5

Import components which are you intend to use and necessary function initTWE. Initialize initTWE in a lifecycle method.

Step 6

Start the app and see if everything's fine. Awesome! You're all set to dive into using TW Elements for your Solid project. Have fun!

Initializing via JS

By default all components have autoinit which means they are initialized by data attributes. But if you want to make init by JavaScript - there is also possibility to do that.

Step 1

Import components which are you intend to use.


Troubleshooting