custom-headless-header
v0.0.1
Published
A header component in tailwind
Downloads
67
Readme
Header Component
Description
The Header
component is a customizable Header component.
Installation
To use the Header
component in your project, you can install it via npm (or include it as part of your component library):
npm install custom-headless-header
Usage
Here’s a simple example of how to use the Header
component in your application:
import React, { useState } from "react";
import { Header } from "custom-headless-header";
const App = () => {
const [checkbox, setCheckbox] = useState(false);
const handleChange = () => {
setCheckbox(!checkbox);
};
return (
<div>
<Header
farLeft={<div className="flex lg:flex-1 cursor-pointer">M.O.R.T</div>}
dropDownOptions={
<li>
<button className="w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
Log out
</button>
</li>
}
headerOptions={
<div className="absolute left-1/2 transform -translate-x-1/2">
<img
src="/your/image/location"
alt=""
className="h-6 w-auto filter invert"
/>
</div>
}
/>
</div>
);
};
export default App;
Props
Header Props
| Prop | Type | Default | Description |
| ----------------- | ----------- | ------- | ------------------------------------------------------------------------------------------------------------------ |
| farLeft
| ReactNode
| - | JSX content displayed on the far left of the header, such as a logo or app name. |
| sectionTitle
| string
| "Hello" | The title displayed in the far right of the header; this also serves as the dropdown trigger. |
| dropDownOptions
| ReactNode
| - | JSX content for the dropdown menu items displayed in the far right of the header, such as Log Out, My Profile etc. |
| headerOptions
| ReactNode
| - | JSX content displayed in the center of the header, typically used for navigational links or additional options. |
Styles
The Header
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 Header
component as needed to fit the design of your application.