@jorgequevedoc/react-gridforms
v1.1.1
Published
A modern React TypeScript implementation of GridForms - a compact and beautiful grid-based form system
Maintainers
Readme
React GridForms
A modern React TypeScript implementation of GridForms - a compact and beautiful grid-based form system with built-in theming support.
Features
- 🎨 Modern Design: Clean, responsive grid-based form layout
- 🌙 Theme Support: Built-in light and dark themes with easy customization
- 📱 Responsive: Works seamlessly across all device sizes
- 🎯 TypeScript: Full TypeScript support with comprehensive type definitions
- ⚡ Performance: Optimized for performance with minimal bundle size
- 🎨 Styled Components: Built with styled-components for flexible styling
Installation
Option 1: Publish to npm (Recommended)
Build the library:
yarn build:libPublish to npm:
npm publishInstall in your project:
yarn add react-gridforms
Option 2: Use as a Git dependency
Add this repository as a dependency in your package.json:
{
"dependencies": {
"react-gridforms": "github:yourusername/react-gridforms#main"
}
}Option 3: Use with yarn link (Development)
Link the library:
cd /path/to/react-gridforms yarn linkLink in your project:
cd /path/to/your-project yarn link react-gridforms
Option 4: Use as a local dependency
Build the library:
cd /path/to/react-gridforms yarn build:libAdd to your project's package.json:
{ "dependencies": { "react-gridforms": "file:/path/to/react-gridforms" } }Install:
yarn install
Usage
Basic Setup
import React from 'react';
import {
GridForm,
FormSection,
FormRow,
FormField,
TextInput,
ThemeProvider,
lightTheme,
} from 'react-gridforms';
function App() {
return (
<ThemeProvider theme={lightTheme}>
<GridForm onSubmit={(data) => console.log(data)}>
<FormSection title="Personal Information">
<FormRow>
<FormField label="First Name">
<TextInput name="firstName" placeholder="Enter your first name" />
</FormField>
<FormField label="Last Name">
<TextInput name="lastName" placeholder="Enter your last name" />
</FormField>
</FormRow>
</FormSection>
</GridForm>
</ThemeProvider>
);
}Available Components
Core Components
GridForm- Main form containerFormSection- Group form fields into sectionsFormRow- Arrange fields in a rowFormField- Individual form field wrapper
Input Components
TextInput- Text input fieldSelectInput- Dropdown select fieldRadioGroup- Radio button group
Theme Components
ThemeProvider- Theme context providerThemeToggle- Toggle between light and dark themes
Theming
import { ThemeProvider, lightTheme, darkTheme, useTheme } from 'react-gridforms';
// Use light theme
<ThemeProvider theme={lightTheme}>
{/* Your form */}
</ThemeProvider>
// Use dark theme
<ThemeProvider theme={darkTheme}>
{/* Your form */}
</ThemeProvider>
// Custom theme
const customTheme = {
...lightTheme,
colors: {
...lightTheme.colors,
primary: '#ff6b6b',
secondary: '#4ecdc4',
}
};
<ThemeProvider theme={customTheme}>
{/* Your form */}
</ThemeProvider>Form Submission
<GridForm
onSubmit={(data) => {
console.log('Form data:', data);
// Handle form submission
}}
>
{/* Form fields */}
</GridForm>API Reference
GridForm Props
onSubmit: (data: Record<string, any>) => void- Form submission handlerchildren: ReactNode- Form content
FormSection Props
title: string- Section titlechildren: ReactNode- Section content
FormRow Props
children: ReactNode- Row content
FormField Props
label: string- Field labelchildren: ReactNode- Input component
TextInput Props
name: string- Field nameplaceholder?: string- Placeholder texttype?: string- Input type (default: "text")required?: boolean- Required fielddisabled?: boolean- Disabled state
SelectInput Props
name: string- Field nameoptions: SelectOption[]- Select optionsplaceholder?: string- Placeholder textrequired?: boolean- Required fielddisabled?: boolean- Disabled state
RadioGroup Props
name: string- Field nameoptions: RadioOption[]- Radio optionsrequired?: boolean- Required fielddisabled?: boolean- Disabled state
Development
Prerequisites
- Node.js 18+
- Yarn
Setup
git clone https://github.com/yourusername/react-gridforms.git
cd react-gridforms
yarn installAvailable Scripts
yarn dev- Start development serveryarn build- Build for productionyarn build:lib- Build library for distributionyarn lint- Run ESLintyarn preview- Preview production build
Project Structure
src/
├── components/ # React components
│ ├── inputs/ # Input components
│ └── index.ts # Component exports
├── theme/ # Theme configuration
├── index.ts # Main library exports
└── lib.ts # Library build entry pointContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For support, please open an issue on GitHub or contact the maintainers.
