@rjsf/shadcn
TypeScript icon, indicating that this package has built-in type declarations

6.0.0-beta.10 • Public • Published

Logo

@rjsf/shadcn

Shadcn theme, fields and widgets for react-jsonschema-form.
Explore the docs »

View Playground · Report Bug · Request Feature

Table of Contents

About The Project

Exports shadcn theme, fields and widgets for react-jsonschema-form.

Live demo

Built With

Getting Started

Prerequisites

  • @rjsf/core >= 6
  • @rjsf/utils >= 6
  • @rjsf/validator-ajv8 >= 6
yarn add @rjsf/core @rjsf/utils @rjsf/validator-ajv8

Installation

yarn add @rjsf/shadcn

Usage

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

All shadcn's default color theme are included in the npm packages. Simply do

import '@rjsf/shadcn/dist/[color].css';
e.g:
import '@rjsf/shadcn/dist/zinc.css';

Supported colors are:

  • default
  • zinc
  • red
  • rose
  • orange
  • green
  • blue
  • yellow
  • violet

Coloring

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 file in /dist/rjsf-shadcn.css in your application

Dark mode (Tailwind only)

Check out this section by shadCN

RTL (Tailwind only)

Installation

npm install @radix-ui/react-direction --save

Implementation

  1. Wrap your layout with DirectionProvider:

    import {DirectionProvider as RadixDirectionProvider} from '@radix-ui/react-direction;
    
    function Layout({children, direction}) {
        return (
            <RadixDirectionProvider dir={direction}>
                {children}
            </RadixDirectionProvider>
        );
    }
  2. Set HTML direction attribute:

    <html dir="rtl" lang="en">
  3. You can refer to direction-context.tsx, direction-provider.tsx and rtl-toggle.tsx from 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

Package Sidebar

Install

npm i @rjsf/shadcn

Weekly Downloads

2,197

Version

6.0.0-beta.10

License

MIT

Unpacked Size

1.06 MB

Total Files

295

Last publish

Collaborators

  • epicfaace
  • rjsf-bot