@rjsf/shadcn
v6.10.1
Published
shadcn theme, fields and widgets for react-jsonschema-form
Readme
Table of Contents
About The Project
Exports shadcn theme, fields and widgets for react-jsonschema-form.
Built With
Getting Started
Prerequisites
@rjsf/core >= 6@rjsf/utils >= 6@rjsf/validator-ajv8 >= 6
yarn add @rjsf/core @rjsf/utils @rjsf/validator-ajv8Installation
yarn add @rjsf/shadcnUsage
import Form from '@rjsf/shadcn';or
import {withTheme} from '@rjsf/core';
import {Theme as shadcnTheme} from '@rjsf/shadcn';
const Form = withTheme(shadcnTheme);Theming
Using Tailwind
Follow shadCN installation guide here for your application
The color of the RJSF will automatically apply with your shadCN config.
Tailwind v3
Add the following line to your tailwind.config.ts
content: [
"./src/**/*.{html,js}",
"node_modules/@rjsf/shadcn/src/**/*.{js,ts,jsx,tsx,mdx}" // Add this line
],Tailwind v4
Add the following line to your equivalent global.css
@source "../node_modules/@rjsf/shadcn";Not using Tailwind
Use the theme on demo site
A prebuilt stylesheet for each bundled theme is included in the npm package. Simply do
import '@rjsf/shadcn/dist/[theme].css';
e.g:
import '@rjsf/shadcn/dist/default.css';Note that these stylesheets are complete Tailwind builds and include Tailwind's preflight reset, so importing one will also restyle the rest of your page. If your application already builds Tailwind, use the Using Tailwind section above instead.
Supported themes are:
- default
- amethyst-haze
- caffeine
- claude
- clean-slate
- neo-brutalism
- pastel-dreams
- soft-pop
- vercel
Coloring
- Generate a theme from official shadCN site or tweakcn
- Navigate to
packages/shadcn/src/css, create a new file called [your-theme].css - Replace the base layer code with your new color
- Follow the next section to build your CSS file
Build your CSS file
If you are not using tailwind but still wants to use this theme, you can follow these steps:
- Clone the repository
cd packages/shadcn
npm i
npm run build:css- Include the built
dist/[your-theme].cssin your application
Dark mode (Tailwind only)
Check out this section by shadCN
RTL (Tailwind only)
Installation
npm install @radix-ui/react-direction --saveImplementation
Wrap your layout with DirectionProvider:
import {DirectionProvider as RadixDirectionProvider} from '@radix-ui/react-direction; function Layout({children, direction}) { return ( <RadixDirectionProvider dir={direction}> {children} </RadixDirectionProvider> ); }Set HTML direction attribute:
<html dir="rtl" lang="en">You can refer to
direction-context.tsx,direction-provider.tsxandrtl-toggle.tsxfrom demo repository for implementation.
Updating to latest shadCN version
- Simply copy the shadcn components into shadcn/src/components/ui and rebuilt the packages or using the shadcn CLI at the root level with the components.json
- For RTL version, you might need component from here by nahasco
- Fancy multi-select
Contributing
Read our contributors' guide to get started.
Contact
rjsf team: https://github.com/orgs/rjsf-team/people
GitHub repository: https://github.com/rjsf-team/react-jsonschema-form

