1.2.60 • Published 11 months ago

@k8pai/tailwind-inputs v1.2.60

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

@k8pai/tailwind-inputs

npm

Include tailwind configured form fields with validations in your React projects easily with tailwind-inputs, which utilizes ES6 imports that allows you to Manage validations and maintainability a piece of cake.

Installation (for standard modern project)

npm install @k8pai/tailwind-inputs --save

example usage

import { TiText } from '@k8pai/tailwind-inputs';

<TiText
	name={'firstName'}
	label={'First Name'}
	value={firstName}
	submit={submit}
	onChange={(e) => setFirstName(e.target.value)}
	validate="default"
	errorMessage="This field should not be empty"
/>;

View the documentation for further usage examples and how to use tailwind-inputs.

Configuration

props usage

KeyTypeDefaultNote
nameStringnullName of the input field
labelStringnullLabel For the input field
valuestate variablenullValue of the input field
submitbooleanfalseForm Submission State, to check field validations
onChangesetState functionnullFunction to update value state variable
validateStringnullCan be set to validate fields
errorMessageStringCustom Error message for validations
classNameStringCan customize Fields with tailwind

Managing state

It's always painful to have a

import React, { useState } from 'react';
import { TiText, TiMail, TiPassword } from '@k8pai/tailwind-inputs';

function Form() {
	const [submit, setSubmit] = useState(false);
	const [formData, setFormData] = useState({
		username: '',
		email: '',
		password: '',
	});

	const handleSubmit = (event) => {
		event.preventDefault();
		setSubmit(true);
		// ... rest of your code goes here
	};

	const handleChange = (event) => {
		const { name, value } = event.target;
		setFormData((prevFormData) => ({
			...prevFormData,
			[name]: value,
		}));
	};

	return (
		<form onSubmit={handleSubmit}>
			<TiText
				name={'username'}
				label={'Username'}
				value={formData.username}
				submit={submit}
				onChange={handleChange}
				validate="default"
			/>
			;
			<TiMail
				name={'email'}
				label={'Mail'}
				value={formData.email}
				submit={submit}
				onChange={handleChange}
				validate="email"
			/>
			;
			<TiPassword
				name={'password'}
				label={'Password'}
				value={firstName}
				submit={submit}
				onChange={handleChange}
				validate="password"
			/>
			;
		</form>
	);
}

Demo

TBD

Related Projects

Licence

MIT

1.2.60

11 months ago

1.2.59

11 months ago

1.2.58

1 year ago

1.2.57

1 year ago

1.2.56

1 year ago

1.2.55

1 year ago

1.2.54

1 year ago

1.2.53

1 year ago

1.2.52

1 year ago

1.2.51

1 year ago

1.2.50

1 year ago

1.2.49

1 year ago

1.2.48

1 year ago

1.2.47

1 year ago

1.2.46

1 year ago

1.2.45

1 year ago

1.2.44

1 year ago

1.2.43

1 year ago

1.2.42

1 year ago

1.2.41

1 year ago

1.2.40

1 year ago

1.2.39

1 year ago

1.2.38

1 year ago

1.2.37

1 year ago

1.2.36

1 year ago

1.2.35

1 year ago

1.2.34

1 year ago

1.2.33

1 year ago

1.2.32

1 year ago

1.2.31

1 year ago

1.2.30

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.28

1 year ago

1.2.27

1 year ago

1.2.25

1 year ago

1.2.24

1 year ago

1.2.23

1 year ago

1.2.21

1 year ago

1.2.20

1 year ago

1.2.19

1 year ago

1.2.18

1 year ago

1.2.17

1 year ago

1.2.16

1 year ago

1.2.15

1 year ago

1.2.14

1 year ago

1.2.13

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.1

1 year ago

1.2.2

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago