This guide covers initial setup for dependencies, Tailwind CSS, and Fomantic UI with theming for this project.
Make sure you have Yarn installed, then run:
yarn installThis will install all dependencies listed in package.json.
If Tailwind is not yet configured:
# Install Tailwind and PostCSS
yarn add -D tailwindcss@3 postcss autoprefixer
# Generate Tailwind config files
npx tailwindcss init -pThis creates:
tailwind.config.jspostcss.config.js
Add this to you index.scss
@tailwind base;
@tailwind components;
@tailwind utilities;You can now use Tailwind classes in your project.
yarn add fomantic-uicd node_modules/fomantic-ui
npx gulp installDuring setup:
- Choose Automatic (Use default locations and all components)
- Accept defaults for everything else
This will create the semantic/ folder with all source files, themes, and gulpfile.js.
Edit semantic/src/theme.config:
@site : 'material'; /* Choose a theme folder from semantic/src/themes */- You can override individual component themes:
@button : 'github';
@menu : 'chubby';
⚠️ If a component theme does not exist for a chosen style, the build will throw an error.
If your project root uses "type": "module", create a package.json inside semantic/:
cd semantic
echo { "type": "commonjs" } > package.jsonThis ensures Gulp runs correctly.
npx gulp build- Compiles your theme into:
semantic/dist/semantic.min.css
semantic/dist/semantic.min.js
- Add types/fomantic-ui.d.ts and add
// If you ever import other Fomantic files, you can broaden it slightly:
// declare module 'fomantic-ui/dist/*';
//declare module 'fomantic-ui/dist/semantic.min.js';
// after building theme
declare module '*semantic/dist/semantic.min.js';
- In your React app (main.tsx), import them like this:
// import before fomantic-js
import $ from 'jquery';
// expose jQuery globally BEFORE loading Fomantic
(window as any).$ = $;
(window as any).jQuery = $;
// load css normally
//import 'fomantic-ui/dist/semantic.min.css';
//after building theme
import '../semantic/dist/semantic.min.css';
// IMPORTANT: load Fomantic dynamically (not static import)
//await import('fomantic-ui/dist/semantic.min.js');
//after building theme
await import('../semantic/dist/semantic.min.js');- Re-run
npx gulp buildwheneversemantic/src/theme.configis changed. - You can safely ignore
semantic/distin Git, only committheme.configandsemantic.json. - You can mix themes per component (e.g., Material globals + GitHub buttons) as described above.