npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pixpilot/formily-shadcn

v1.11.27

Published

Formily integration for shadcn/ui components

Downloads

2,938

Readme

@pixpilot/formily-shadcn

Formily integration for shadcn/ui components. Build powerful, schema-driven forms with shadcn/ui's beautiful components and Formily's reactive form management.

Features

  • 🎨 Shadcn/ui Integration - Uses shadcn/ui components for consistent design
  • 📝 JSON Schema Support - Define forms using JSON Schema
  • Reactive State Management - Built on @formily/reactive for optimal performance
  • 🔄 Dynamic Forms - Support for dynamic arrays, conditional fields, and complex layouts
  • 📐 Grid Layout - Built-in responsive grid layout with FormGrid
  • Validation - Comprehensive validation with error display
  • 🎯 Type Safe - Full TypeScript support

Installation

pnpm add @pixpilot/formily-shadcn @formily/core @formily/react

Quick Start

Basic Form

import { createForm, Form, SchemaField } from '@pixpilot/formily-shadcn';

const form = createForm();

const schema = {
  type: 'object',
  properties: {
    username: {
      type: 'string',
      title: 'Username',
      required: true,
      'x-decorator': 'FormItem',
      'x-component': 'Input',
      'x-component-props': {
        placeholder: 'Enter your username',
      },
    },
    email: {
      type: 'string',
      title: 'Email',
      required: true,
      'x-decorator': 'FormItem',
      'x-component': 'Input',
      'x-component-props': {
        type: 'email',
        placeholder: 'Enter your email',
      },
    },
  },
};

function MyForm() {
  return (
    <Form
      form={form}
      layout={{ density: 'comfortable' }}
      onSubmit={(values) => console.log(values)}
    >
      <SchemaField schema={schema} />
      <button type="submit">Submit</button>
    </Form>
  );
}

Grid Layout

const schema = {
  type: 'void',
  'x-component': 'FormGrid',
  properties: {
    field1: {
      type: 'string',
      title: 'Field 1 (Span 2)',
      'x-decorator': 'FormItem',
      'x-decorator-props': { className: 'col-span-2' },
      'x-component': 'Input',
    },
    field2: {
      type: 'string',
      title: 'Field 2',
      'x-decorator': 'FormItem',
      'x-component': 'Input',
    },
  },
};

Array Fields

import {
  Field,
  ArrayField as FormilyArrayField,
  FormItem,
  Input,
} from '@pixpilot/formily-shadcn';

<FormilyArrayField name="contacts">
  {(field) => (
    <div>
      {field.value?.map((_, index) => (
        // eslint-disable-next-line react/no-array-index-key
        <div key={index}>
          <Field
            name={`contacts.${index}.name`}
            title="Name"
            decorator={[FormItem]}
            component={[Input]}
          />
          <button onClick={() => field.remove(index)}>Remove</button>
        </div>
      ))}
      <button onClick={() => field.push({})}>Add Contact</button>
    </div>
  )}
</FormilyArrayField>;

Available Components

Form Components

  • Form - Main form wrapper with FormProvider
  • FormItem - Field decorator with label, error messages
  • FormGrid - Responsive grid layout

Input Components

  • Input - Text input
  • Textarea - Multi-line text input
  • NumberInput - Number input
  • Checkbox - Checkbox input
  • Radio - Radio group
  • Select - Select dropdown

Field Components

  • SchemaField - Renders forms from JSON Schema

Schema Properties

Common x-properties

  • x-component: Component to render (e.g., 'Input', 'Select')
  • x-decorator: Wrapper component (typically 'FormItem')
  • x-component-props: Props passed to the component
  • x-decorator-props: Props passed to the decorator

Documentation

Form Layout Options

Learn how to configure form layout and visual settings using the FormLayoutOptions interface:

  • Density - Control spacing between form elements (compact, normal, comfortable, responsive)
  • Description Placement - Configure where field descriptions appear (top, bottom, popover)
  • Label Placement - Set label position relative to inputs (top, bottom, start, end)
  • Custom Classes - Apply custom CSS classes to form elements

Read the full documentation →

JSON Schema Form: Headless vs Default Pattern

Learn about the difference between JsonSchemaFormRenderer (headless) and JsonSchemaForm (batteries-included) components:

  • JsonSchemaFormRenderer - Pure, headless component that requires you to provide all components explicitly. Ideal for custom component registries and bundle size optimization.
  • JsonSchemaForm - Convenience wrapper that comes pre-loaded with all standard components (Slider, Combobox, TagsInput, etc.). Perfect for getting started quickly.

Read the full documentation →

API Reference

createForm

Creates a form instance with reactive state management.

const form = createForm({
  initialValues: {},
  effects: () => {},
});

Form Configuration

useFieldNameAsLabel

The useFieldNameAsLabel option controls whether field names are automatically converted to labels when no explicit label is provided.

Default Behavior:

  • JsonSchemaFormRenderer - Sets useFieldNameAsLabel: true by default. Field names are automatically capitalized and used as labels if no title is provided in the schema.
  • Form component - Must be explicitly configured. Users need to set useFieldNameAsLabel: true in the config prop to enable this behavior.

Example with JsonSchemaFormRenderer (enabled by default):

import { JsonSchemaFormRenderer } from '@pixpilot/formily-shadcn';

const schema = {
  type: 'object',
  properties: {
    userName: {
      type: 'string',
      'x-decorator': 'FormItem',
      'x-component': 'Input',
      // No title provided - will use "User Name" as label
    },
  },
};

export function MyForm() {
  return <JsonSchemaFormRenderer schema={schema} />;
}

Example with Form component (requires explicit configuration):

import { createForm, Form, SchemaField } from '@pixpilot/formily-shadcn';

const form = createForm();

const schema = {
  type: 'object',
  properties: {
    userName: {
      type: 'string',
      'x-decorator': 'FormItem',
      'x-component': 'Input',
      // No title provided - will use "User Name" as label only if config is set
    },
  },
};

export function MyForm() {
  return (
    <Form
      form={form}
      config={{
        label: {
          useFieldNameAsLabel: true, // Must be explicitly set
        },
      }}
    >
      <SchemaField schema={schema} />
    </Form>
  );
}

The label resolution priority is:

  1. Explicit label prop (if provided and not false)
  2. Schema title field
  3. Field name capitalized (only if useFieldNameAsLabel: true)
  4. No label