Reusable UI components for WordPress plugins. Built with React and designed to work seamlessly with the WordPress admin environment.
- Installation
- Quick Start
- Development Setup
- Building the Package
- Importing Styles
- Usage Examples
- Components
- Theme & Variables Mapping
- Theme Presets
- Project Structure
- Available Scripts
- Peer Dependencies
- License
Add the package to your package.json dependencies:
Option A: Via GitHub (Recommended)
{
"dependencies": {
"@wedevs/plugin-ui": "git+https://github.com/getdokan/plugin-ui.git"
}
}Option B: Local Development If you are developing locally and want to link the package:
{
"dependencies": {
"@wedevs/plugin-ui": "file:../path/to/plugin-ui"
}
}Run the installation command:
npm installImport the CSS file in your main entry point:
import '@wedevs/plugin-ui/styles.css';import { TextField, Button, Alert, Badge } from '@wedevs/plugin-ui';const MyComponent = () => {
const [text, setText] = useState('');
return (
<div className="space-y-4">
<Alert variant="success" label="Success">
The implementation is working perfectly!
</Alert>
<Badge variant="info" label="New Feature" />
<TextField
value={text}
onChange={setText}
placeholder="Enter some text..."
/>
<Button variant="primary">Click Me</Button>
</div>
);
};This project requires Node.js 24. We recommend using nvm to manage your Node version.
# Use the Node version specified in .nvmrc
nvm usegit clone https://github.com/getdokan/plugin-ui.git
cd plugin-uinpm installnpm run buildThis will:
- Compile TypeScript files to JavaScript (
dist/) - Process CSS with PostCSS and Tailwind (
dist/styles.css)
If you want to use this package in another project during development:
# In plugin-ui directory
npm link
# In your consuming project
npm link @wedevs/plugin-uiBuild both TypeScript and CSS:
npm run buildThis runs:
npm run build:ts- Compiles TypeScript to JavaScriptnpm run build:css- Processes CSS with PostCSS/Tailwind
npm run build:tsnpm run build:cssAfter building, you'll find:
- JavaScript:
dist/**/*.js(compiled from TypeScript) - Type Definitions:
dist/**/*.d.ts(TypeScript declarations) - CSS:
dist/styles.css(processed stylesheet)
In your main application file (e.g., src/index.tsx or src/admin/index.tsx):
import '@wedevs/plugin-ui/styles.css';This package requires Tailwind CSS 4. In your main CSS file:
@import "tailwindcss";
/* Optional: Override plugin-ui CSS variables */
:root {
--plugin-ui-primary: #6366f1;
--plugin-ui-primary-hover: #4f46e5;
}Check your browser's developer tools to ensure styles.css is loaded correctly.
import { TextField, Button, Alert, FieldLabel } from '@wedevs/plugin-ui';
const LoginForm = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const handleSubmit = () => {
if (!email || !password) {
setError('Please fill in all fields');
return;
}
// Handle login
};
return (
<form onSubmit={handleSubmit} className="space-y-4">
{error && (
<Alert variant="error" label="Error">
{error}
</Alert>
)}
<FieldLabel label="Email" required>
<TextField
type="email"
value={email}
onChange={setEmail}
placeholder="Enter your email"
/>
</FieldLabel>
<FieldLabel label="Password" required>
<PasswordField
value={password}
onChange={setPassword}
placeholder="Enter your password"
/>
</FieldLabel>
<Button type="submit" variant="primary">
Login
</Button>
</form>
);
};import { SearchInput, Badge, Modal, List } from '@wedevs/plugin-ui';
const DataView = () => {
const [search, setSearch] = useState('');
const [isModalOpen, setIsModalOpen] = useState(false);
return (
<div className="space-y-4">
<div className="flex items-center gap-4">
<SearchInput
value={search}
onChange={setSearch}
placeholder="Search..."
/>
<Button onClick={() => setIsModalOpen(true)}>
Add New
</Button>
</div>
<List>
<List.Item>
<div className="flex items-center justify-between">
<span>Item 1</span>
<Badge variant="success" label="Active" />
</div>
</List.Item>
</List>
<Modal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
title="Add New Item"
>
{/* Modal content */}
</Modal>
</div>
);
};Alert- Notice/Message with variants (success, info, warning, error)Badge- Status indicator (requireslabelprop)InfoBox- Informational block with title and contentTooltip- Hover tooltip for additional information
Button- Styled buttons with multiple variants and loading statesLink- Styled link componentSocialButton- Social media login buttons (Google, etc.)
TextField- Standard text inputNumberField- Numeric input with validationTextArea- Multi-line text inputPasswordField- Secure password input with show/hide toggleSelect- Dropdown selection with searchCheckbox&CheckboxGroup- Boolean and multiple selectionRadio&RadioCapsule- Single selection from a groupSwitch- Toggle switch componentFieldLabel- Wrapper for input labels with descriptionsColorPicker- Color selection inputTimePicker- Time selection inputFileUpload- File upload with drag & dropMediaUploader- WordPress Media Library integration
SearchInput- Input with search icon and clearing logicDebouncedInput- Input that delaysonChangeexecutionCustomizeRadio- Rich radio options (Cards, Templates, etc.)AsyncSelect- Async data loading select componentsProductAsyncSelectVendorAsyncSelectOrderAsyncSelectCouponAsyncSelect
RichText- Quill-based rich text editorCopyField- Read-only field with copy functionalityShowHideField- Field with show/hide toggle
List- Versatile list display for activities or itemsModal- Accessible dialog windowsPopover- Popover component for additional contentRepeater- Repeating field groupsFilter- Filter component for data views
VisitStore- Store visit link component
Design tokens (ThemeTokens) are converted to CSS variables and wired into Tailwind’s theme. For a full description of how tokens map to base CSS variables and to Tailwind theme variables, see docs/VARIABLES-MAPPING.md.
Summary:
- ThemeTokens (camelCase in JS) → Base CSS variables (e.g.
--primary-foreground) viatokensToCssVariables()inThemeProvider. - Base variables → Tailwind theme via
@theme inlineinstyles.css(e.g.--color-primary: var(--primary)). - Custom token keys are converted the same way (
camelCase→--kebab-case).
The package includes theme presets — ready-made light/dark token sets you can pass to ThemeProvider. For the full list, usage with ThemeProvider, and how to extend them with createTheme / createDarkTheme, see docs/THEME-PRESETS.md.
Quick example:
import { ThemeProvider, dokanTheme, dokanDarkTheme } from "@wedevs/plugin-ui";
<ThemeProvider pluginId="dokan" tokens={dokanTheme} darkTokens={dokanDarkTheme}>
<App />
</ThemeProvider>Available presets: defaultTheme, dokanTheme, blueTheme, greenTheme, amberTheme, slateTheme (and their *DarkTheme variants). Use createTheme(tokens) or createDarkTheme(tokens) to build a custom theme from a base.
plugin-ui/
├── src/
│ ├── components/ # React components
│ │ ├── Alert.tsx
│ │ ├── Button.tsx
│ │ ├── TextField.tsx
│ │ └── ...
│ ├── hooks/ # Custom React hooks
│ │ ├── useClickOutside.ts
│ │ ├── useClipboard.ts
│ │ └── useToggle.ts
│ ├── utils/ # Utility functions
│ │ └── classnames.ts
│ ├── types/ # TypeScript type definitions
│ ├── styles.css # Main stylesheet (Tailwind + custom)
│ └── index.ts # Main entry point
├── dist/ # Build output (generated)
│ ├── components/
│ ├── hooks/
│ ├── utils/
│ ├── styles.css # Compiled CSS
│ └── index.js
├── package.json
├── tsconfig.json # TypeScript configuration
├── postcss.config.js # PostCSS configuration
└── README.md
# Build the entire package (TypeScript + CSS)
npm run build
# Build TypeScript only
npm run build:ts
# Build CSS only
npm run build:css
# Run type checking without emitting files
npm run typecheck
# Lint source files
npm run lint-
TypeScript Compilation (
build:ts)- Compiles
.tsand.tsxfiles to JavaScript - Generates type definitions (
.d.tsfiles) - Output:
dist/**/*.jsanddist/**/*.d.ts
- Compiles
-
CSS Processing (
build:css)- Processes
src/styles.csswith PostCSS - Applies Tailwind CSS 4 transformations
- Output:
dist/styles.css
- Processes
-
Automatic Build (
prepare)- Runs automatically on
npm install - Ensures package is built before publishing
- Runs automatically on
This package requires the following peer dependencies. Make sure they are installed in your consuming project:
@wordpress/block-editor>= 12.0.0@wordpress/components>= 19.0.0@wordpress/element>= 4.0.0@wordpress/hooks>= 3.0.0@wordpress/i18n>= 4.0.0
react>= 17.0.0react-dom>= 17.0.0
quill>= 1.3.0 (for RichText component)
Edit files in the src/ directory:
- Components:
src/components/*.tsx - Styles:
src/styles.css - Hooks:
src/hooks/*.ts - Utils:
src/utils/*.ts
After making changes, rebuild the package:
npm run buildIf using npm link, changes will be reflected in your consuming project after rebuilding.
Verify TypeScript types are correct:
npm run typecheckCheck code quality:
npm run lint-
Ensure you've imported the CSS:
import '@wedevs/plugin-ui/styles.css';
-
Verify Tailwind CSS 4 is set up in your project
-
Check that
dist/styles.cssexists after building
- Run
npm run typecheckto see all type errors - Ensure all peer dependencies are installed
- Check TypeScript version compatibility
-
Clear
dist/directory and rebuild:rm -rf dist && npm run build -
Reinstall dependencies:
rm -rf node_modules package-lock.json npm install
GPL-2.0-or-later