custom-headless-date-field
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

DateField Component

Description

The DateField component is a customizable Date field component.

Installation

To use the DateField component in your project, you can install it via npm (or include it as part of your component library):

npm install custom-headless-date-field"

Usage

Here’s a simple example of how to use the DateField component in your application:

import React, { useState } from "react";
import { DateField } from "rcustom-headless-date-field";

const App = () => {
  const [dob, setDOB] = useState("");

  return (
    <div>
      <DateField
        label={"Date of Birth"}
        selectedDate={dod} // Ensure this matches the prop name
        handleDateChange={(e) => setDOB(e.target.value)} // Function to handle date changes
        className={
          "hover:ring-2 ring-olive-green focus:ring-2 focus:ring-inset focus:ring-olive-green"
        }
      />
    </div>
  );
};

export default App;

Props

DateField Props

Prop Type Description
label React.ReactNode Label to assign to the field.
selectedDate string Variable that holds the date selected
handleDateChange function A callback function that is called to save the DateField value
className string Variable that holds the custom class for the date field (optional)

Styles

The DateField component is styled using Tailwind CSS classes. Make sure to include Tailwind CSS in your project to apply the styles correctly.

Example CSS Setup

If you haven’t set up Tailwind CSS yet, here’s a basic example of how to do it:

  1. Install Tailwind CSS:
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
  1. Configure your tailwind.config.js file:
module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}", "./public/index.html"],
  theme: {
    extend: {},
  },
  plugins: [],
};
  1. Include Tailwind in your CSS file: Add the following lines to your main CSS file to include Tailwind’s base, components, and utilities:
@tailwind base;
@tailwind components;
@tailwind utilities;

Customization

Feel free to customize the Tailwind classes used in the DateField component as needed to fit the design of your application.

Readme

Keywords

none

Package Sidebar

Install

npm i custom-headless-date-field

Weekly Downloads

97

Version

0.0.2

License

ISC

Unpacked Size

51.1 kB

Total Files

27

Last publish

Collaborators

  • donaboueid