Skip to content
loseta

Components / Forms

Button

Displays a button or a component that looks like a button.

Status stableWorks with spinner
<button type="button" class="btn">Button</button>

Installation

pnpm dlx loseta add button
npx loseta add button

Examples

Variants

<div style="display: flex; flex-wrap: wrap; gap: 0.5rem">
  <button type="button" class="btn">Default</button>
  <button type="button" class="btn" data-variant="secondary">Secondary</button>
  <button type="button" class="btn" data-variant="outline">Outline</button>
  <button type="button" class="btn" data-variant="ghost">Ghost</button>
  <button type="button" class="btn" data-variant="link">Link</button>
  <button type="button" class="btn" data-variant="destructive">Destructive</button>
</div>

Sizes

<div style="display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem">
  <button type="button" class="btn" data-size="xs">Extra small</button>
  <button type="button" class="btn" data-size="sm">Small</button>
  <button type="button" class="btn">Default</button>
  <button type="button" class="btn" data-size="lg">Large</button>
</div>

Icon buttons

<div style="display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem">
  <button type="button" class="btn" data-size="icon-xs" aria-label="Add"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M12 5v14"/></svg></button>
  <button type="button" class="btn" data-size="icon-sm" aria-label="Search"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg></button>
  <button type="button" class="btn" data-size="icon" aria-label="Next"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button>
  <button type="button" class="btn" data-size="icon-lg" aria-label="More options"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></button>
</div>

With icons

<div style="display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem">
  <button type="button" class="btn"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-icon="inline-start"><line x1="6" x2="6" y1="3" y2="15"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/></svg>New branch</button>
  <button type="button" class="btn" data-variant="outline"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-icon="inline-start"><circle cx="12" cy="18" r="3"/><circle cx="6" cy="6" r="3"/><circle cx="18" cy="6" r="3"/><path d="M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"/><path d="M12 12v3"/></svg>Fork</button>
  <button type="button" class="btn" data-variant="ghost">Continue<svg data-icon="inline-end" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button>
</div>

Rounded

<div style="display: flex; flex-wrap: wrap; gap: 0.5rem">
  <button type="button" class="btn" style="border-radius: var(--radius-full)">Get started</button>
  <button type="button" class="btn" data-variant="outline" style="border-radius: var(--radius-full)">Documentation</button>
</div>

Loading

<div style="display: flex; flex-wrap: wrap; gap: 0.5rem">
  <button type="button" class="btn" aria-busy="true"><span class="spinner" data-icon="inline-start" aria-hidden="true"></span>Generating</button>
  <button type="button" class="btn" data-variant="outline" aria-busy="true"><span class="spinner" data-icon="inline-start" aria-hidden="true"></span>Downloading</button>
</div>

Disabled and invalid

<div style="display: flex; flex-wrap: wrap; gap: 0.5rem">
  <button type="button" class="btn" disabled>Disabled</button>
  <button type="button" class="btn" data-variant="outline" disabled>Disabled</button>
  <button type="button" class="btn" aria-invalid="true">Invalid</button>
</div>
<div style="display: flex; flex-wrap: wrap; gap: 0.5rem">
  <a class="btn" href="#">Login</a>
  <a class="btn" data-variant="outline" href="#">Read the docs</a>
</div>

Right-to-left

<div dir="rtl" style="display: flex; flex-wrap: wrap; gap: 0.5rem">
  <button type="button" class="btn"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-icon="inline-start"><line x1="6" x2="6" y1="3" y2="15"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/></svg>New branch</button>
  <button type="button" class="btn" data-variant="outline"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-icon="inline-start"><circle cx="12" cy="18" r="3"/><circle cx="6" cy="6" r="3"/><circle cx="18" cy="6" r="3"/><path d="M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"/><path d="M12 12v3"/></svg>Fork</button>
</div>

Accessibility and behavior

  • Use data-variant and data-size for the public variants. Mark inline icons with data-icon="inline-start|inline-end"; icon-only buttons need an accessible label. aria-invalid and aria-expanded are supported states. Apply .btn to an <a> for link actions without adding role="button".

Files

components/button.cssbase
styles/nova/button.cssstyle

Install contract

The CLI writes the base file under components/, the visual file for the selected style under styles/<name>/, and any primitive dependency underprimitives/. The generated index.css imports them in the right layer order.

← Back to components

loseta is MIT licensed. Built with native CSS, no runtime. Inspired byshadcn/ui.