A working demo of React components nested within ServiceNow's Snabbdom components, featuring full shadcn/ui integration with proper styling in the shadow DOM.
- Hybrid Architecture: Snabbdom parent component with React child components
- React 18 Support: Full React 18 hooks and features via
@quixomatic/ui-renderer-react-simple
- shadcn/ui Integration: Complete shadcn/ui components with proper styling
- Tailwind CSS: Configured for shadow DOM with CSS variables support
- ServiceNow Shadow DOM: Properly isolated styles that work within ServiceNow's shadow DOM
This project demonstrates:
- ✅ React components rendering inside ServiceNow shadow DOM
- ✅ shadcn/ui components with full styling support
- ✅ Tailwind CSS with shadow DOM compatibility
- ✅ Interactive form handling with React state management
- ✅ CSS variables properly configured for both
:root
and:host
src/
├── index.js # Main component export
├── components/ui/ # shadcn/ui components
│ ├── button.jsx # Button component
│ ├── input.jsx # Input component
│ ├── label.jsx # Label component
│ ├── card.jsx # Card component
│ └── textarea.jsx # Textarea component
├── lib/utils.js # Utility functions (cn, etc)
├── styles/tailwind.css # Tailwind CSS configuration
└── x-312987-tf-form-v-2/ # Main component
├── index.js # Component definition (Snabbdom)
├── styles.scss # Component styles
├── styles/_tailwind-generated.css # Generated Tailwind CSS
└── components/ # Sub-components
└── shadcn-example/ # React shadcn/ui example
├── index.js # React component registration
├── view.js # React component implementation
└── styles.scss # Component styles with Tailwind
# Install the React renderer and React 18
npm install @quixomatic/ui-renderer-react-simple react@18 react-dom@18
# Install shadcn/ui dependencies
npm install @radix-ui/react-label @radix-ui/react-slot class-variance-authority clsx tailwind-merge lucide-react
# Install Tailwind CSS
npm install tailwindcss@^3.4.17
Run the automated setup:
# Set up the fake @servicenow/ui-renderer-react package
npx setup-servicenow-react
# Patch the babel plugin (if needed)
node patch-babel-plugin.js
Generate the Tailwind CSS for shadow DOM:
# Build Tailwind CSS with shadow DOM support
npm run build:css-prod
This generates src/x-312987-tf-form-v-2/styles/_tailwind-generated.css
with:
- CSS variables for both
:root
and:host
(shadow DOM compatibility) - All shadcn/ui utility classes
- Proper styling for the shadow DOM environment
# Start development server
snc ui-component develop
# Build for production
snc ui-component build
# Watch Tailwind CSS changes during development
npm run build:css
- React components render correctly within ServiceNow's shadow DOM
- Full React 18 features including hooks and state management
- Proper event handling and component lifecycle
- Complete shadcn/ui components (Button, Input, Label, Card, Textarea)
- All variants and sizes working properly
- Proper focus states and accessibility
- CSS variables defined for both
:root
and:host
- Automatic shadow DOM compatibility
- All utility classes available to React components
- Communication between Snabbdom parent and React child components
- ServiceNow's dispatch/action system for component communication
- React state management with hooks
tailwind.config.js
- Tailwind configuration with shadow DOM supportcomponents.json
- shadcn/ui configurationjsconfig.json
- Path mapping for importspackage.json
- Build scripts for CSS generation
- CSS Generation:
npm run build:css-prod
generates Tailwind CSS with shadow DOM variables - Component Build:
snc ui-component build
builds the ServiceNow component - Development:
npm run build:css
watches for Tailwind changes during development
MIT