A visual condition builder for creating complex logical expressions with nested groups and rules.
✅ Nested Groups with AND/OR operators
✅ Add, edit, and delete rules
✅ Unlimited nesting depth
✅ Real-time validation
✅ JSON preview
✅ Built with React + TypeScript + Tailwind CSS
npm installnpm run devOpen http://localhost:5173 in your browser.
npm run buildThe built files will be in the dist directory.
- Add Rule: Click "+ Rule" to add a new condition
- Add Group: Click "+ Group" to create a nested group
- Toggle Operator: Click the AND/OR button to switch logical operators
- Edit Rule:
- Select a field (Price, Category, Rating)
- Choose an operator (>, <, =, !=, >=, <=, contains)
- Enter a value
- Delete: Click the × button or "Delete Group" button
react-condition-builder/
├── src/
│ ├── components/
│ │ ├── ConditionBuilder.tsx # Main container
│ │ ├── ConditionGroup.tsx # Recursive group component
│ │ └── ConditionRule.tsx # Rule component
│ ├── hooks/
│ │ └── useConditionTree.ts # State management hook
│ ├── types.ts # TypeScript definitions
│ ├── utils.ts # Helper functions
│ ├── App.tsx # Root component
│ ├── main.tsx # Entry point
│ └── index.css # Tailwind CSS
├── index.html
├── package.json
├── vite.config.ts
├── tailwind.config.js
└── tsconfig.json
- React 18 - UI library
- TypeScript - Type safety
- Tailwind CSS - Utility-first styling
- Vite - Build tool and dev server
# Initialize repository
git init
git add .
git commit -m "Initial commit: React Condition Builder"
# Push to GitHub
git remote add origin https://github.com/YOUR_USERNAME/react-condition-builder.git
git branch -M main
git push -u origin mainCreate .github/workflows/deploy.yml:
name: Deploy
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install
- run: npm run build
- uses: actions/configure-pages@v3
- uses: actions/upload-pages-artifact@v2
with:
path: './dist'
- uses: actions/deploy-pages@v2Then enable GitHub Pages in repository settings.
MIT