Module library

The blocks every app ends up building

72 modules in 6 groups. Each is built from the component kit, takes its data and copy as props, emits events, and never fetches. Mobile first at 320px, themed with CSS variables in light, dark and forced colors, and usable by keyboard and screen reader. Import from $lib/modules.

Every one is free and MIT-licensed. The demos below run on fake local data, so nothing you type leaves this page.

Account

SignInForm

Email and password sign-in with show/hide password, "keep me signed in", optional provider buttons (OAuth), and loading and error states.

Try the password wrong-password to see the error state.

Accessibility. A labelled form in a section named by its heading (level is a prop). Fields have real labels, autocomplete tokens (username, current-password) and aria-invalid + aria-describedby errors. A failed submit moves focus to an error summary whose links jump to each field; a server failure is announced as an alert. While loading the button sets aria-busy and ignores clicks without being disabled, so focus is not lost.

Code
import { SignInForm } from '$lib/modules';

<SignInForm
  providers={[{ id: 'github', label: 'Continue with GitHub' }]}
  loading={busy}
  error={failure}
  forgotHref="/reset"
  signUpHref="/sign-up"
  on:submit={(e) => signIn(e.detail)}
  on:provider={(e) => startOAuth(e.detail.id)}
/>

SignUpForm

Name, email and password with a live strength meter and requirement checklist, a terms checkbox, and field-level errors.

Use [email protected] to see a server field error.

Accessibility. Each field shows its own error, tied with aria-invalid and aria-describedby; the password field also points at the strength meter and checklist. Strength is a word, and every requirement says met or not met in text, so nothing rests on colour. Failed submits focus an error summary; the terms label is a slot so it can hold links.

Code
import { SignUpForm } from '$lib/modules';

<SignUpForm
  errors={serverErrors}
  loading={busy}
  signInHref="/sign-in"
  on:submit={(e) => register(e.detail)}
>
  <span slot="terms">I accept the <a href="/terms">terms</a></span>
</SignUpForm>

PasswordStrength

A strength meter and a checklist of password requirements, for any new-password field.

Password strength: Not entered yet

Your password needs:

  • At least 8 characters (not met)
  • A lowercase letter (not met)
  • An uppercase letter (not met)
  • A number (not met)
  • A symbol (not met)

Accessibility. The bar is decorative; the strength word is a status region announced when it changes, and each requirement carries "(met)" or "(not met)" for screen readers. Link a password input to it with aria-describedby. Honours forced-colors.

Code
import { PasswordStrength } from '$lib/modules';

<input type="password" bind:value={password} aria-describedby="pw-strength" />
<PasswordStrength id="pw-strength" {password} />

FormErrorSummary

A list of everything wrong in a form, each item a link to its field.

Please fix the following

Accessibility. A labelled section with a heading (level is a prop) that takes focus when you call focus() after a failed submit, so a screen reader reads it. Each link moves focus into its field. It renders nothing when there are no errors.

Code
import { FormErrorSummary } from '$lib/modules';

<FormErrorSummary
  bind:this={summary}
  {errors}
  fields={[{ name: 'email', label: 'Email', id: 'email' }]}
/>

PasswordResetFlow

Three steps: request an email, enter the code (one-time-code input), set a new password, with a stepper and a resend countdown.

Reset your password

  1. Email (Current step)
  2. Code (Not started)
  3. New password (Not started)

Reset your password

We will send a code to this address.

Any email works. In a real app you would hold the step until the server answers (autoAdvance=false).

Accessibility. A Stepper marks the current step with aria-current. Each step change moves focus to that step's heading. The code is one labelled group of cells with one-time-code autocomplete. Resend is disabled with the time left in its text, and a polite status says when it is ready again. Errors are summarised and tied to their fields.

Code
import { PasswordResetFlow } from '$lib/modules';

<PasswordResetFlow
  bind:step
  autoAdvance={false}
  loading={busy}
  error={failure}
  on:request={(e) => sendCode(e.detail.email)}
  on:verify={(e) => checkCode(e.detail)}
  on:reset={(e) => changePassword(e.detail)}
  on:done={() => goto('/sign-in')}
/>

ProfileForm

Avatar upload with preview, name, email and a bio with a character counter. Tracks what changed and offers Save and Discard.

Profile

Profile photo

PNG, JPEG, WebP or GIF, up to 2 MB.

24 / 160

A sentence or two about you.

No changes yet.

Accessibility. The photo picker is a real button that opens the file dialog; picking a bad file shows its reason in text. Save and Discard are disabled until something changes, and a polite status says "You have unsaved changes" in words. The bio counter is announced politely. Errors are summarised and tied to their fields.

Code
import { ProfileForm } from '$lib/modules';

<ProfileForm
  {initial}
  saving={busy}
  saved={ok}
  on:save={(e) => save(e.detail)}
  on:discard={() => (ok = false)}
/>

SessionsList

Signed-in devices with a "Current session" badge, last-active times, revoke one, and revoke all others behind a confirmation.

Active sessions

Devices where you are signed in.

  • Firefox on Linux Current session

    Phoenix, US Last active:

  • Safari on iPhone

    Portland, US Last active:

  • Chrome on Windows

    Boston, US Last active:

  • Edge on Windows

    Lewiston, US Last active:

Sign out of all other sessions?

This signs out 3 other sessions. You stay signed in here.

Accessibility. A list of sessions; the current one carries a text badge, not only a colour. Each Revoke button is named for its device ("Revoke session on Firefox on Linux"). Times are real <time> elements. "Sign out of all other sessions" opens an alert dialog with Cancel focused. After a revoke, a status says which device was signed out and focus returns to the heading.

Code
import { SessionsList } from '$lib/modules';

<SessionsList
  {sessions}
  now={Date.now()}
  revoking={pendingIds}
  on:revoke={(e) => revoke(e.detail.id)}
  on:revokeAll={(e) => revokeMany(e.detail.ids)}
/>

DangerZone

Delete the account behind a type-to-confirm step in an alert dialog.

Delete account

Permanently delete your account and everything in it. This cannot be undone.

Delete your account?

All your data will be erased for good. This cannot be undone.

Accessibility. The dialog is an alertdialog on the native <dialog>: focus is trapped, Cancel is focused first and Escape cancels. Pressing delete before the phrase matches keeps the dialog open, explains what to type in text and moves focus to the field. The button describes itself with the warning text.

Code
import { DangerZone } from '$lib/modules';

<DangerZone
  confirmPhrase={account.name}
  deleting={busy}
  on:delete={() => deleteAccount()}
/>

TwoFactorSetup

Authenticator setup: QR code slot, copyable secret, verify the code, then recovery codes to copy or download.

Set up two-factor authentication

  1. Scan the QR code

    Open your authenticator app and scan this code.

    QR code appears here

    Or enter the key by hand

    Setup key

    JBSW Y3DP EHPK 3PXP
  2. Enter the code

    Type the 6-digit code your app shows.

    Authentication code
  3. Save your recovery codes

    Your recovery codes appear after you verify the code.

Accessibility. An ordered list of three parts, each with a heading. The secret is selectable text with a Copy button, for people who cannot scan. The code is a labelled one-time-code group with a text error. Copy and download results are announced in a status region. Finish stays disabled until "I have saved my recovery codes" is ticked.

Code
import { TwoFactorSetup } from '$lib/modules';

<TwoFactorSetup
  secret={secret}
  recoveryCodes={codes}
  verified={ok}
  error={failure}
  on:verify={(e) => check(e.detail.code)}
  on:complete={() => close()}
>
  <img slot="qr" src={qrDataUrl} alt="QR code for your authenticator app" />
</TwoFactorSetup>

AccountSwitcher

A menu of accounts or organisations with the current one marked, and an optional "add account" row.

Current account: Ada Lovelace

Accessibility. The ARIA menu-button pattern with radio items. Enter, Space or arrows open it on the current account; arrows, Home and End move and skip disabled accounts; a letter jumps to the next match; Escape closes and returns focus to the button. The current account has aria-checked, a check mark and the word "current" for screen readers.

Code
import { AccountSwitcher } from '$lib/modules';

<AccountSwitcher
  {accounts}
  bind:current
  addLabel="Add account"
  on:select={(e) => switchTo(e.detail.id)}
  on:add={() => goto('/accounts/new')}
/>

Settings

AppearanceSettings

NotificationPreferences

ApiKeysManager

WebhooksManager

PrivacyControls

LanguageRegionSettings

IntegrationsList

SettingsLayout

Marketing

Hero

FeatureGrid

PricingTable

ComparisonTable

LogoCloud

StatsStrip

FaqSection

NewsletterSignup

ContactForm

CtaBanner

AnnouncementBar

TeamGrid

App shell

AppShell

NotificationCenter

UserMenu

OnboardingChecklist

Wizard

ErrorState

EmptyStateCard

ConfirmDialog

TabsPageNav

Toolbar

BottomNav

Data & teams

DataGrid

FilterBar

KanbanBoard

ActivityFeed

CommentThread

TeamMembers

FileManager

CalendarSchedule

TreeView

AuditLog

Commerce

BillingOverview

UsageMeters

InvoiceList

PaymentMethodCard

PaymentMethodForm

CheckoutForm

CartSummary

OrderStatusTracker

ProductCard

ReviewsRatings

RatingStars

StatusPage

ChangelogList

WaitlistSignup

CouponBanner