Button
React Button components are used to trigger actions such as submitting forms, opening dialogs, or starting processes. They are a core part of user interaction across interfaces.
This Button component is built with React and styled using Tailwind CSS, giving developers control over appearance, size, and interaction states.
Installation
Usage
Import the component and pass the required props.
import { Button } from "@/registry/core/button";
export default () => <Button variant="primary">Click me</Button>;Examples
Variants
Use variants to indicate the purpose of an action.
<Button variant="primary">Primary</Button>
<Button variant="danger">Danger</Button>
<Button variant="success">Success</Button>
<Button variant="ghost">Ghost</Button>Appearances
Use appearances to control the visual style.
<Button appearance="fill">Filled</Button>
<Button appearance="outline">Outline</Button>Sizes
Choose a size that fits the surrounding UI.
<Button size="xs">Extra Small</Button>
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>With Icons
Icons are automatically adjusted based on the size and variant props
import { PlusAdd, Download } from "@tailgrids/icons";
<Button>
<PlusAdd />
Add Item
</Button>
<Button iconOnly>
<Download />
</Button>Disabled
Use the disabled state to prevent interaction.
<Button disabled>Disabled Button</Button>API Reference
Extends button element props.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'primary', 'danger', 'success', 'ghost' | 'primary' | Visual style variant |
appearance | 'fill', 'outline' | 'fill' | Filled or outlined style |
size | 'xs', 'sm', 'md', 'lg' | 'md' | Button size |
iconOnly | boolean | false | Icon-only button (square aspect) |
className | string | - | Additional CSS classes |
children | React.ReactNode | - | Button content |
disabled | boolean | false | Disable button interaction |
Accessibility
- Uses
type="button"by default to avoid accidental form submission - Includes focus ring styling with
focus:ring-3for keyboard navigation - Disabled state removes pointer events and applies appropriate visual styling
- Icons inherit text color for consistent styling
- All standard button HTML attributes are supported
Notes
- Icons are automatically adjusted based on the
sizeandvariantprops - The
iconOnlyprop adjusts padding to create square buttons for icon-only usage - Ghost variant automatically adjusts focus ring size to
ring-2for subtler appearance - Disabled buttons have
pointer-events-noneto prevent interaction