This documentation provides an overview of the components included in the code snippet and their usage. It includes information about the available props, their functionality, and the elements within each component that can be styled.
The components provided follow a modular approach, allowing developers to easily incorporate them into their projects. Each component focuses on a specific functionality and can be customized using Tailwind CSS utility classes. These components are designed to enhance user interfaces and provide interactive elements for a seamless user experience.
You can check out the components demo on: https://simple-tailwind-components.vercel.app/
The Avatar component displays a user's profile picture along with a fallback display when the image is unavailable.
import Avatar from "@/components/avatar/Avatar";
// Usage Example
<Avatar>
<Avatar.Image
src="https://d2qp0siotla746.cloudfront.net/img/use-cases/profile-picture/template_3.jpg"
alt="profile picture"
/>
<Avatar.Fallback>AD</Avatar.Fallback>
</Avatar>
None
Avatar.Image: Renders the user's profile picture.
Avatar.Fallback: Displays a fallback display when the profile picture is unavailable.
The Avatar component can be styled using Tailwind CSS utility classes.
The Badge component is used to highlight specific information with various types and styles.
import Badge from "@/components/badge/Badge";
// Usage Example
<Badge>Default</Badge>
<Badge type="info">Info</Badge>
<Badge type="success">Success</Badge>
<Badge type="warning">Warning</Badge>
<Badge type="error">Error</Badge>
type (optional): Determines the type of badge. Available options are "error," "info," "warning," "success," and "default." Default value is "default".
None
The Badge component can be styled using Tailwind CSS utility classes.
The type prop can be used to apply different colors and styles to the badge based on the selected type.
The Dropdown component creates a dropdown menu with customizable content.
import Dropdown from "@/components/dropdown/Dropdown";
<Dropdown>
<Dropdown.Trigger className="px-5 py-2 bg-blue-500 rounded">Open Dropdown</Dropdown.Trigger>
<Dropdown.Content className="w-64 py-2 bg-white rounded top-14 absolute text-black text-sm">
{/* Dropdown Content */}
</Dropdown.Content>
<Dropdown.Overlay />
</Dropdown>
None
Dropdown.Trigger: Renders the trigger button to open the dropdown.
Dropdown.Content: Displays the content of the dropdown.
Dropdown.Overlay: Covers the screen when the dropdown is open to prevent interaction with other elements.
The Dropdown component can be styled using Tailwind CSS utility classes.
The Hover component reveals additional content when hovering over a specific element.
import Hover from "@/components/hover/Hover";
// Usage Example
<Hover>
<Hover.Trigger>
{/* Trigger Element */}
</Hover.Trigger>
<Hover.Content>
{/* Content to display on hover */}
</Hover.Content>
</Hover>
Props:
None
Hover.Trigger: Specifies the element that triggers the hover effect.
Hover.Content: Displays the content when hovering over the trigger element.
The Hover component can be styled using Tailwind CSS utility classes.
The Modal component creates a modal dialog with customizable content.
import Modal from "@/components/modal/Modal";
// Usage Example
<Modal>
<Modal.Trigger className="bg-blue-500 px-5 py-2 text-white rounded">Open Modal</Modal.Trigger>
<Modal.Content className="bg-white rounded flex flex-col justify-between text-black p-5 max-w-sm">
{/* Modal Content */}
</Modal.Content>
<Modal.Overlay className="bg-black/50 backdrop-blur-sm" />
</Modal>
Props:
None
Modal.Trigger: Renders the button that opens the modal.
Modal.Content: Displays the content of the modal.
Modal.Close: Renders the button that closes the modal.
Modal.Overlay: Covers the screen behind the modal to prevent interaction with other elements.
The Modal component can be styled using Tailwind CSS utility classes.
The Progress component represents a progress bar with a customizable fill.
import Progress from "@/components/progress/Progress";
// Usage Example
<Progress
value={sliderValue}
className="w-full max-w-sm bg-blue-950 h-4 flex flex-col items-start rounded-full mx-auto"
>
<Progress.Value className="text-xs self-center" />
<Progress.Fill className="bg-blue-500 duration-200" />
</Progress>
value (optional): Determines the progress value. Default value is 0.
Progress.Value: Displays the current progress value.
Progress.Fill: Represents the fill of the progress bar.
The Progress component can be styled using Tailwind CSS utility classes.
The Slider component allows users to select a value within a defined range.
import Slider from "@/components/slider/Slider";
// Usage Example
<Slider
className="bg-blue-500 text-blue-500 w-full max-w-[200px]"
value={sliderValue}
onChange={setSliderValue}
/>
value: Represents the current value of the slider.
onChange: Callback function triggered when the slider value changes.
None
The Slider component can be styled using Tailwind CSS utility classes.
The Toast component displays temporary notifications to provide feedback or important information to users.
import Toast from "@/components/toast/Toast";
// Usage Example
<button onClick={() => setToastOpen(true)} className="bg-blue-500 text-white cursor-pointer px-5 py-2 rounded">
Open Toast
</button>
<Toast open={toastOpen} onOpenChange={setToastOpen}>
<Toast.Content className="bg-white rounded shadow flex flex-col">
{/* Toast Content */}
</Toast.Content>
</Toast>
open: Determines whether the toast is open or closed.
onOpenChange: Callback function triggered when the toast open state changes.
Toast.Content: Displays the content of the toast.
Toast.Close: Renders the button to close the toast.
The Toast component can be styled using Tailwind CSS utility classes.