Overview
The Button component is a fundamental form element built on top of theHtmlAtom component. It provides a consistent, accessible button interface with support for different button types and preset-based styling.
Installation
Basic Usage
Examples
Button Types
Custom Styling
With Preset
Disabled State
Props
The HTML button type attribute. Controls the button’s behavior in forms.
The preset key used for styling. Allows customization through the preset system.
Additional CSS classes to apply to the button element.
The content to render inside the button.
When true, the button is disabled and cannot be interacted with.
HTML Attributes
The Button component accepts all standard HTML button attributes throughHTMLAttributes<HTMLButtonElement>, including:
onclick- Click event handlerid- Element IDname- Form field namevalue- Button valueautofocus- Auto-focus on mount- And all other standard button attributes
Default Styling
The Button component comes with built-in Tailwind CSS classes:TypeScript Support
The Button component is fully typed with TypeScript:Extending Button Props
You can extend the Button component with custom properties:Accessibility
- The Button component uses semantic
<button>element - Supports keyboard navigation (Space/Enter to activate)
- Properly handles disabled state
- Works with form submission when
type="submit"
Integration with Forms
Best Practices
- Use appropriate button types: Use
type="submit"for form submissions,type="reset"for form resets, andtype="button"(default) for other interactions - Provide clear labels: Button text should clearly indicate what action will be performed
- Handle disabled state: Show visual feedback when buttons are disabled
- Use presets for consistency: Define button variants in your preset configuration for consistent styling across your app