Button

Button - Phlex implementation

Examples

Primary

The default button style.

<%= render "ui/button", content: "Button" %>

Secondary

A secondary button style.

<%= render "ui/button", variant: "secondary", content: "Secondary" %>

Destructive

A destructive button for dangerous actions.

<%= render "ui/button", variant: "destructive", content: "Destructive" %>

Outline

An outline button style.

<%= render "ui/button", variant: "outline", content: "Outline" %>

Ghost

A ghost button style.

<%= render "ui/button", variant: "ghost", content: "Ghost" %>

Sizes

Different button sizes.

<div class="flex flex-wrap items-center gap-4">
  <%= render "ui/button", size: "sm", content: "Small" %>
  <%= render "ui/button", size: "default", content: "Default" %>
  <%= render "ui/button", size: "lg", content: "Large" %>
</div>

Disabled

A disabled button.

<%= render "ui/button", disabled: true, content: "Disabled" %>

Icon

A button with only an icon.

<%= render "ui/button", variant: "outline", size: "icon" do %>
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>
<% end %>

With Icon

A button with an icon and text.

<%= render "ui/button" do %>
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>
  Upload
<% end %>

Rounded

A fully rounded button.

<%= render "ui/button", classes: "rounded-full", content: "Rounded" %>

Loading

A button in loading state.

<%= render "ui/button", disabled: true do %>
  <svg class="animate-spin -ml-1 mr-2 size-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
    <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
    <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
  </svg>
  Please wait
<% end %>

Features

  • Custom styling with Tailwind classes
  • Disabled state support
  • ARIA attributes for accessibility

API Reference

Button

A versatile button component with multiple variants and sizes.

Parameters

NameTypeDefaultDescription
variantStringdefaultVisual style variant
sizeStringdefaultSize of the element
typeStringbuttonThe type
disabledBooleanfalseWhether the element is disabled

Group

A container that groups related buttons together with consistent styling.

Parameters

NameTypeDefaultDescription
orientationSymbol:horizontalOrientation (horizontal or vertical)

Accessibility

Implements the WAI-ARIA Button pattern with proper roles, states, and keyboard navigation.