custom-headless-checkbox
v0.0.5
Published
Smaller mt for checkbox
Downloads
332
Readme
Checkbox Component
Description
The Checkbox
component is a customizable input field for checking a Checkbox on and off.
Installation
To use the Checkbox
component in your project, you can install it via npm (or include it as part of your component library):
npm install custom-headless-checkbox@latest
Usage
Here’s a simple example of how to use the Checkbox
component in your application:
import React, { useState } from "react";
import { Checkbox } from "custom-headless-checkbox";
const App = () => {
const [checkbox, setCheckbox] = useState(false);
const handleChange = () => {
setCheckbox(!checkbox);
};
return (
<div>
<Checkbox
handleRequiredChange={handleChange}
checkboxTitle={"Required"}
value={checkbox}
/>
</div>
);
};
export default App;
Props
Checkbox Props
| Prop | Type | Description |
| ---------------------- | ---------- | ---------------------------------------------------------------------- |
| checkboxTitle
| string
| Text to display next to the checkbox |
| value
| boolean
| Variable that holds the checkbox value (true/false) |
| handleRequiredChange
| function
| A callback function that is called to update the value of the checkbox |
| className
| string
| Variable that holds the custom class for the date field (optional) |
Styles
The Checkbox
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:
- Install Tailwind CSS:
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
- Configure your tailwind.config.js file:
module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}", "./public/index.html"],
theme: {
extend: {},
},
plugins: [],
};
- 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 Checkbox
component as needed to fit the design of your application.