Skip to content

Get started

HTML + CSS

The kit as plain CSS classes and one small script. For any stack that renders HTML: Go, Django, Rails, Laravel, htmx or a static page. No React, no build step.

Why

You render HTML on the server and want the Astabyte look. This is for you.

  • Works with Go html/template, htmx, Rails, Django, Laravel or a plain HTML file.
  • Same look as the React kit, light and dark.
  • Menus, dialogs, tabs and toasts run on asta.js. It wires itself with event delegation, so markup swapped in by htmx just works.

Install

Quick start. Two lines in your <head>. The stylesheet is already built and minified.

<link rel="stylesheet" href="https://ui.astabyte.com/cdn/asta.css">
<script src="https://ui.astabyte.com/cdn/asta.js" defer></script>

Temporary: this link may move or go away. For production, pin a version from jsDelivr:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/asta.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/css/asta.js" defer></script>

With your own Tailwind v4 build. Install the package and import the tokens and the components. Your utilities still work next to the kit classes, and they win over them.

npm install asta-ui

Serve asta.js from wherever your app keeps static files. components.css already tells Tailwind to scan it, so the classes it adds to toasts and menus get built.

Components

Every class starts with asta-. Keep the data-asta-*, role and aria-* attributes from the snippets. That is what asta.js looks for.

Buttons

Pick a variant and a size. The label goes in asta-btn-label, so the spinner can sit on top during an htmx request.

<button class="asta-btn asta-btn-accent"><span class="asta-btn-label">Save</span></button>
<button class="asta-btn asta-btn-outline asta-btn-sm"><span class="asta-btn-label">Cancel</span></button>
<a class="asta-btn asta-btn-ghost" href="/docs"><span class="asta-btn-label">Docs</span></a>

<button class="asta-btn asta-btn-accent" hx-post="/save">
  <span class="asta-btn-label">Save</span>
  <span class="asta-btn-spinner" aria-hidden="true">
    <svg viewBox="0 0 16 16" fill="none">
      <circle cx="8" cy="8" r="6" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" />
      <path d="M14 8a6 6 0 0 0-6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
    </svg>
  </span>
</button>

Form field

A label, the control, then a hint or an error. Set aria-invalid="true" on the input and the field turns red.

<div class="asta-field">
  <div class="asta-field-head">
    <label class="asta-label" for="email">Email</label>
  </div>
  <label class="asta-input">
    <input class="asta-input-control" id="email" name="email" type="email" placeholder="[email protected]">
  </label>
  <p class="asta-hint">We never share it.</p>
</div>

Select, checkbox, switch

Native controls underneath, so forms post as usual.

<div class="asta-select">
  <select class="asta-select-control" name="plan">
    <option value="" disabled hidden selected>Choose a plan</option>
    <option>Starter</option>
    <option>Pro</option>
  </select>
  <svg class="asta-select-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6"><path d="m4 6 4 4 4-4" /></svg>
</div>

<label class="asta-checkbox">
  <span class="asta-checkbox-box">
    <input type="checkbox" class="asta-checkbox-input" name="updates" checked>
    <svg class="asta-checkbox-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.4"><path d="M3.5 8.5l3 3 6-7" /></svg>
    <span class="asta-checkbox-dash"></span>
  </span>
  <span><span class="asta-checkbox-label">Email me updates</span></span>
</label>

<label class="asta-switch">
  <span><span class="asta-switch-label">Deploy alerts</span></span>
  <span class="asta-switch-track">
    <input type="checkbox" role="switch" class="asta-switch-input" name="alerts">
    <span class="asta-switch-thumb"></span>
  </span>
</label>

Dialog

A native <dialog>. Any element with data-asta-open="id" opens it. data-asta-close closes it. Escape and a click on the backdrop close it too.

<button class="asta-btn asta-btn-accent" data-asta-open="invite">
  <span class="asta-btn-label">Invite</span>
</button>

<dialog id="invite" class="asta-dialog" aria-labelledby="invite-title">
  <button type="button" class="asta-dialog-close" data-asta-close aria-label="Close">
    <svg viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.7"><path d="M3 3l8 8M11 3 3 11" /></svg>
  </button>
  <h2 id="invite-title" class="asta-dialog-title">Invite to Astabyte</h2>
  <p class="asta-dialog-desc">They get an email with a link.</p>
  <form class="asta-dialog-body" hx-post="/invite" hx-target="this" hx-swap="outerHTML">
    <label class="asta-input"><input class="asta-input-control" name="email" type="email"></label>
    <div class="asta-dialog-footer">
      <button type="button" class="asta-btn asta-btn-ghost" data-asta-close><span class="asta-btn-label">Cancel</span></button>
      <button class="asta-btn asta-btn-accent"><span class="asta-btn-label">Send invite</span></button>
    </div>
  </form>
</dialog>

Menu

Arrow keys, Escape and outside clicks are handled. The menu flips above the trigger when there is no room below.

<div class="asta-menu" data-asta-menu>
  <button type="button" class="asta-btn asta-btn-outline asta-menu-trigger"
    data-asta-menu-trigger aria-haspopup="menu" aria-expanded="false">
    Actions
    <svg class="asta-menu-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7"><path d="m4 6 4 4 4-4" /></svg>
  </button>
  <div role="menu" hidden tabindex="-1" class="asta-menu-panel">
    <button type="button" role="menuitem" tabindex="-1" class="asta-menu-item">
      <span class="asta-menu-item-text">Rename</span><kbd class="asta-menu-shortcut">R</kbd>
    </button>
    <div role="separator" class="asta-menu-separator"></div>
    <button type="button" role="menuitem" tabindex="-1" class="asta-menu-item asta-menu-item-danger"
      hx-delete="/projects/astabyte">
      <span class="asta-menu-item-text">Delete</span>
    </button>
  </div>
</div>

Tabs

The indicator slides to the selected tab. A hidden panel gets an asta:show event the first time it opens, ready for hx-trigger.

<div class="asta-tabs" data-asta-tabs>
  <div role="tablist" aria-label="Project" class="asta-tabs-list">
    <span class="asta-tabs-line" aria-hidden="true"></span>
    <span class="asta-tabs-indicator" data-asta-tab-indicator aria-hidden="true"></span>
    <button type="button" role="tab" class="asta-tab" id="tab-a" aria-controls="panel-a" aria-selected="true">Overview</button>
    <button type="button" role="tab" class="asta-tab" id="tab-b" aria-controls="panel-b" aria-selected="false" tabindex="-1">
      Activity <span class="asta-tab-count">3</span>
    </button>
  </div>
  <div role="tabpanel" class="asta-tabs-panel" id="panel-a" aria-labelledby="tab-a" tabindex="0">…</div>
  <div role="tabpanel" class="asta-tabs-panel" id="panel-b" aria-labelledby="tab-b" tabindex="0" hidden
    hx-get="/projects/astabyte/activity" hx-trigger="asta:show once">…</div>
</div>

Table

<div class="asta-table-wrap">
  <div class="asta-table-scroll">
    <table class="asta-table">
      <thead>
        <tr>
          <th class="asta-th" scope="col">Client</th>
          <th class="asta-th asta-th-right" scope="col">Amount</th>
        </tr>
      </thead>
      <tbody>
        <tr class="asta-tr">
          <td class="asta-td">Astabyte Studio</td>
          <td class="asta-td asta-td-right">$1,200.00</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

Server templates

There is nothing to install on the server. Loop over your data and print the classes. For an error, set aria-invalid and render an asta-error line. Every component page has the full markup in its "HTML + CSS" step.

{{range .Members}}
<tr class="asta-tr">
  <td class="asta-td">{{.Name}}</td>
  <td class="asta-td asta-td-right">{{.Role}}</td>
</tr>
{{end}}

<label class="asta-input">
  <input class="asta-input-control" name="email" value="{{.Email}}"
    {{if .EmailErr}}aria-invalid="true"{{end}}>
</label>
{{with .EmailErr}}<p class="asta-error" role="alert">{{.}}</p>{{end}}

htmx

Load htmx next to asta.js. Nothing else to set up: asta.js listens on document, so menus, dialogs and tabs in swapped-in markup work without re-init.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.min.js" defer></script>
  • A button with asta-btn-spinner shows it while its request runs (htmx-request).
  • A tab panel gets asta:show the first time it opens, so hx-trigger="asta:show once" loads it lazily.
  • Send toasts from the server with HX-Trigger (below).

Toasts

From JavaScript. asta.js puts one function on window.asta.

asta.toast({ title: "Saved", tone: "success" })
asta.toast({ title: "Deleted", action: { label: "Undo", event: "undo" } })
asta.open("invite")
asta.close("invite")

From the server. Send an HX-Trigger header with an asta:toast event. Any language works. Here is Go:

func save(w http.ResponseWriter, r *http.Request) {
  // …save…
  w.Header().Set("HX-Trigger", `{"asta:toast": {"title": "Saved", "tone": "success"}}`)
  w.WriteHeader(http.StatusNoContent)
}

After a redirect. Put a template in the page and the toasts show on load.

<template data-asta-toast='[{"title": "Welcome back"}]'></template>

Class names

  • A component is asta-<name>. Its parts are asta-<name>-<part>.
  • Variants and sizes are extra classes on the root: asta-btn asta-btn-accent asta-btn-sm.
  • States come from attributes: aria-selected, aria-invalid, data-open, disabled.
  • Core: asta-btn, asta-input, asta-field, asta-textarea, asta-select, asta-checkbox, asta-radio, asta-switch, asta-slider, asta-badge, asta-count, asta-dialog, asta-menu, asta-tabs, asta-table
  • Display: asta-avatar, asta-avatar-group, asta-kbd, asta-spinner, asta-tooltip, asta-skeleton, asta-progress, asta-alert, asta-breadcrumb, asta-pagination, asta-accordion, asta-stat-card, asta-empty-state
  • Forms: asta-rating, asta-copy-button, asta-toggle-group, asta-range-slider, asta-color-picker, asta-inline-edit, asta-segmented, asta-number-input, asta-tag-input, asta-date-picker, asta-combobox, asta-file-upload, asta-otp-input, asta-password, asta-sr-only
  • Overlays and navigation: asta-drawer, asta-popover, asta-hover-card, asta-context-menu, asta-dropdown, asta-cmd, asta-navbar, asta-sidebar, asta-ws, asta-footer, asta-announcement, asta-stepper, asta-tool-dock
  • Data: asta-motion-button, asta-timeline-root, asta-carousel-root, asta-tree-view, asta-file-card, asta-file-row, asta-image-compare, asta-data-table, asta-kanban-root, asta-comments-root, asta-event-calendar, asta-notification-center
  • Blocks: asta-ai-chat, asta-sign-in, asta-onboarding, asta-plans, asta-checkout-form, asta-properties, asta-settings-panel, asta-team-members
  • Modules: asta-countdown, asta-meter, asta-menubar, asta-phone, asta-sortable, asta-consent, asta-chart-card, asta-invoice, asta-inbox, asta-files, asta-billing, asta-testimonials

A few roots pair with a class asta.js styles, like asta-timeline asta-timeline-root or asta-kanban asta-kanban-root. Keep both. Toasts have no markup to write: asta.js builds them.

Every class has a short markup example in its source file: packages/asta-ui/css/src.

Theming

Colours are CSS variables. Override them after the stylesheet to rebrand. Put class="dark" on <html> for dark mode.

:root {
  --brand: #0f766e;   /* your accent */
  --paper: #ffffff;   /* page ground */
}
.dark {
  --brand: #2dd4bf;
}

The kit classes live in the components layer. Any plain CSS you write, or any utility class, wins over them without !important.

Versions

Pin the version in the URL, like asta-ui@0.9.9. A bare asta-ui follows the latest release and can change under you. The CSS ships with every npm release, next to the React package. See the releases.

Next Prompts