Button

Button component documentation for Velyx. Installation, usage examples, variants, and customization guidance for Laravel Blade, Alpine.js, Livewire, and Tailwind CSS v4.

Button

Buttons allow users to perform actions or navigate with a single click.

Installation

Add the button component to your project:

npx velyx@latest add button
pnpm dlx velyx@latest add button
yarn dlx velyx@latest add button
bunx --bun velyx@latest add button

Usage

Primary Button

Button

primary

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Secondary Button

Button

secondary

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Destructive Button

Button

destructive

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Outline Button

Button

outline

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Ghost Button

Button

ghost

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Sizes

Button

primary

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Button

primary

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

With Icon

Button

primary

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Loading State

Button

primary

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Disabled

Button

primary

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Pill Shape

Button

primary

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Icon Button

Button

ghost

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Button

Full preview from the registry iframe.

Loading preview...

Props

Prop Type Default Description
variant string primary Button style variant
size string md Button size (xs, sm, md, lg, xl)
type string button Button type (button, submit, reset)
disabled boolean false Disable the button
loading boolean false Show loading spinner
icon string null Icon name (left side)
iconRight string null Icon name (right side)
iconOnly boolean false Icon-only button
pill boolean false Rounded pill shape
block boolean false Full width button
href string null URL for link buttons
action string null Livewire action to target

Variants

  • default - Default styling
  • primary - Primary action button
  • secondary - Secondary action button
  • outline - Outlined button
  • ghost - Minimal styling, hover only
  • destructive - Dangerous action (delete, remove)

Sizes

  • sm - Small button
  • default - Default size
  • lg - Large button
  • icon - Square button for icons

Examples

Submit Form

<form method="POST" action="/submit">
    @csrf
    <x-button type="submit">Submit</x-button>
</form>

Link Button

<a href="{{ route('dashboard') }}">
    <x-button>Go to Dashboard</x-button>
</a>

Disabled State

<x-button disabled>
    Disabled
</x-button>

Full Width

<x-button class="w-full">
    Full Width Button
</x-button>

Customization

The button component uses Tailwind CSS classes. You can customize the appearance by modifying the component in your project:

@

@props([
    'variant' => 'primary',
    'size' => 'md',
    // ... other props
])

@php
$variantClasses = match($variant) {
    'primary' => 'bg-primary text-primary-foreground hover:bg-primary/90',
    'secondary' => 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
    // ... customize variants here
};
@endphp

<button {{ $attributes->class([$variantClasses]) }}>
    {{ $slot }}
</button>

Accessibility

Buttons include proper ARIA attributes and keyboard support:

  • Tab - Focus button
  • Enter/Space - Activate button
  • Disabled state - Automatically applied

Next Steps