Add the UAE Design System to your project using Vite — the fastest way to wire up Tailwind CSS v4 and the component library together.
Not using Vite? See Other build tools below. Using React, Vue, or Angular? See Framework packages below.
Install the package
Starting from nothing? Create a Vite project first, then run the steps below inside it:
npm create vite@latest my-app -- --template vanilla-ts
cd my-app
npm install
Install @aegov/designsystem via npm.
npm install @aegov/designsystem
Install the Tailwind CSS Vite plugin
Install tailwindcss and @tailwindcss/vite via npm.
npm install -D tailwindcss @tailwindcss/vite
Configure the Vite plugin
Create vite.config.ts in the project root — the Vite starter templates don't include one — and add the @tailwindcss/vite plugin. If your project already has a Vite config (the React and Vue templates do), add tailwindcss() to its existing plugins array instead.
// vite.config.ts
import { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [tailwindcss()],
});
Import the CSS
Create src/styles.css with these three lines, in this order. If you started from a Vite template, delete its src/style.css — it styles the template's demo page, not your app.
/* src/styles.css */
@import "tailwindcss";
@import "@aegov/designsystem/base";
@import "@aegov/designsystem/theme";
The order matters: tailwindcss brings Tailwind's reset, and the design system's base styles must come after it. Import them the other way round and the reset wins — for example, headings drop to plain 16px text.
Register the components
Replace the contents of src/main.ts with the lines below. They load your stylesheet and call defineCustomElements() once to register every aegov-* tag. (The template's main.ts renders a demo counter you no longer need; you can also delete src/counter.ts and src/assets/.)
// src/main.ts
import './styles.css';
import { defineCustomElements } from '@aegov/designsystem/loader';
defineCustomElements();
Start using components
Write your markup in index.html, inside <body>. Replace the template's <div id="app"></div> and keep the <script> tag that loads src/main.ts. Any aegov-* tag works straight away — no further registration is needed.
<!-- index.html -->
<body>
<main class="aegov-container py-10">
<aegov-button variant="primary" size="lg">Submit application</aegov-button>
</main>
<script type="module" src="/src/main.ts"></script>
</body>
Run npm run dev and open the address it prints.
Other build tools
npm install @aegov/designsystem
npm install -D webpack webpack-cli webpack-dev-server html-webpack-plugin css-loader style-loader postcss-loader @tailwindcss/postcss postcss
If your package.json has "type": "commonjs" (the npm init -y default), remove that line — otherwise webpack refuses to parse the import statements in src/index.js.
Create these files. src/styles.css holds the same three lines as Step 4:
// postcss.config.js
module.exports = {
plugins: {
// optimize: flatten nesting and add vendor prefixes for all supported browsers
'@tailwindcss/postcss': { optimize: true },
},
};
Keep optimize: true. Vite and Parcel turn it on for production builds themselves, but with webpack, Rollup or the PostCSS CLI it is off unless you set it, and the CSS then keeps nested rules that older supported browsers ignore — link hover, focus, dark-mode and RTL styles stop working there.
/* src/styles.css */
@import "tailwindcss";
@import "@aegov/designsystem/base";
@import "@aegov/designsystem/theme";
// src/index.js
import './styles.css';
import { defineCustomElements } from '@aegov/designsystem/loader';
defineCustomElements();
<!-- src/index.html -->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<main class="aegov-container py-10">
<aegov-button variant="primary" size="lg">Submit application</aegov-button>
</main>
</body>
</html>
// webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/index.js',
module: {
rules: [
{ test: /\.css$/i, use: ['style-loader', 'css-loader', 'postcss-loader'] },
],
},
plugins: [new HtmlWebpackPlugin({ template: './src/index.html' })],
};
npx webpack serve # dev server on http://localhost:8080
npx webpack --mode production # production build to dist/
HtmlWebpackPlugin adds the built script to the page for you — there is no <script> tag to write.
npm install @aegov/designsystem
npm install -D parcel @tailwindcss/postcss postcss
If your package.json has a "main" field (npm init -y adds "main": "index.js"), delete it — Parcel otherwise treats the project as a library and both commands below fail.
Create these files. Parcel picks up .postcssrc.json automatically, and src/styles.css holds the same three lines as Step 4:
// .postcssrc.json
{
"plugins": {
"@tailwindcss/postcss": {}
}
}
/* src/styles.css */
@import "tailwindcss";
@import "@aegov/designsystem/base";
@import "@aegov/designsystem/theme";
<!-- index.html -->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="./src/styles.css" />
</head>
<body>
<main class="aegov-container py-10">
<aegov-button variant="primary" size="lg">Submit application</aegov-button>
</main>
<script type="module">
import { defineCustomElements } from '@aegov/designsystem/loader';
defineCustomElements();
</script>
</body>
</html>
npx parcel index.html # dev server on http://localhost:1234
npx parcel build index.html # production build to dist/
Both commands write to dist/, so running the dev server after a build replaces the production files with a development build. Run npx parcel build last before you deploy.
</p> when it is the last thing inside any custom element (including aegov-*). The HTML spec doesn't allow that inside custom elements, so the browser leaves the paragraph open, and the components that follow end up nested inside it. npx parcel (dev) isn't affected. Until Parcel fixes it, turn off only the HTML minifier with a .parcelrc file next to package.json.
// .parcelrc
{
"extends": "@parcel/config-default",
"optimizers": {
"*.{html,xhtml}": []
}
}
JavaScript and CSS are still minified; only the HTML file is left as written.
npm install @aegov/designsystem
npm install -D rollup rollup-plugin-postcss @tailwindcss/postcss postcss @rollup/plugin-node-resolve
Add "type": "module" to package.json — the config below uses import, and with the npm init -y default ("type": "commonjs") Rollup cannot load it. If you already have "type": "commonjs", change it to "module".
Create these files. src/styles.css holds the same three lines as Step 4:
/* src/styles.css */
@import "tailwindcss";
@import "@aegov/designsystem/base";
@import "@aegov/designsystem/theme";
// src/main.js
import './styles.css';
import { defineCustomElements } from '@aegov/designsystem/loader';
defineCustomElements();
Set output.dir (not output.file) so Rollup can split the loader's per-component chunks into separate files — the same lazy loading as the other bundlers:
// rollup.config.js
import resolve from '@rollup/plugin-node-resolve';
import postcss from 'rollup-plugin-postcss';
import tailwindcssPostcss from '@tailwindcss/postcss';
export default {
input: 'src/main.js',
output: { dir: 'dist', format: 'es' },
plugins: [
resolve(),
// optimize: flatten nesting and add vendor prefixes for all supported browsers
postcss({ plugins: [tailwindcssPostcss({ optimize: true })], extract: 'styles.css' }),
],
};
Keep optimize: true — without it the CSS keeps nested rules that older supported browsers ignore, so link hover, focus, dark-mode and RTL styles stop working there.
Rollup does not create an HTML page, so add one that loads the two built files:
<!-- index.html -->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="./dist/styles.css" />
</head>
<body>
<main class="aegov-container py-10">
<aegov-button variant="primary" size="lg">Submit application</aegov-button>
</main>
<script type="module" src="./dist/main.js"></script>
</body>
</html>
npx rollup -c # build to dist/
npx serve . # serve the project root, then open the URL it prints
Compile the CSS with the PostCSS CLI, and load the pre-built, self-registering component bundle directly — no loader and no defineCustomElements() call.
npm install @aegov/designsystem
npm install -D @tailwindcss/postcss postcss postcss-cli
Create these files. src/styles.css holds the same three lines as Step 4:
// postcss.config.js
module.exports = {
plugins: {
// optimize: flatten nesting and add vendor prefixes for all supported browsers
'@tailwindcss/postcss': { optimize: true },
},
};
Keep optimize: true. Vite and Parcel turn it on for production builds themselves, but with webpack, Rollup or the PostCSS CLI it is off unless you set it, and the CSS then keeps nested rules that older supported browsers ignore — link hover, focus, dark-mode and RTL styles stop working there.
/* src/styles.css */
@import "tailwindcss";
@import "@aegov/designsystem/base";
@import "@aegov/designsystem/theme";
<!-- index.html -->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="./dist/styles.css" />
</head>
<body>
<main class="aegov-container py-10">
<aegov-button variant="primary" size="lg">Submit application</aegov-button>
</main>
<script type="module" src="./node_modules/@aegov/designsystem/dist/aegov/aegov.esm.js"></script>
</body>
</html>
npx postcss src/styles.css -o dist/styles.css # compile the CSS
npx serve . # serve the project root, then open the URL it prints
Without postcss.config.js the command still succeeds but copies the @import lines unchanged, and the page loads unstyled. Serve the project root (not a subfolder) so the browser can reach node_modules, and re-run the postcss command whenever you add Tailwind classes to index.html.
Framework packages
| Package | Registration |
|---|---|
@aegov/designsystem-react |
automatic, per wrapper |
@aegov/designsystem-vue |
app.use(ComponentLibrary), mounting once defineDesignSystem() resolves; or automatic, per typed component |
@aegov/designsystem-angular |
automatic, per wrapper; provideDesignSystem() from @aegov/designsystem-angular/provider for the global setup |
Each framework has its own dedicated guide — install, CSS, registration, props/events casing, refs, SSR, validation, and the gotchas that catch people out:
Troubleshooting
@import lines never went through Tailwind. Check DevTools → Elements → :root for --color-primary-600 — if it's missing, confirm @tailwindcss/postcss / @tailwindcss/vite is wired into your build.
defineCustomElements() executes before the tags are used, and that the page is served over http:// or https://, not file://.