Zubra UI
Code for
GitHub

signin-block

A sign-in form: email, password with show and hide, keep me signed in, reset and sign-up links, and an error that's announced. Submitting fires signin; with an action it also posts as a plain form.

Try it: events appear here (signin).

Source: signin-block.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/signin-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/signin-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/signin-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/signin-block.json
One file, no dependencies (5.6 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/signin-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/signin-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/signin-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/signin-block.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/signin-block.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/signin-block.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/signin-block.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/signin-block.json
No build: a script tag, straight from this site
HTML
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/signin-block.js"></script>

The compiled install writes src/components/zubra/signin-block.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed , with the plain elements of the components it's made of; it's smaller on a page with one to three components, the shared runtime with more.

Usage

index.html
<signin-block
  heading="Sign in"
  intro="Welcome back to the bake sale planner."
  forgot-href="#forgot"
  signup-href="#signup"
></signin-block>

<script type="module">
  import './components/zubra/signin-block.js';

  const element = document.querySelector('signin-block');
  element.addEventListener('signin', (event) => console.log('signin', event.detail));
</script>
Example.jsx
import './components/zubra/signin-block.js';

export function SigninBlockExample() {
  return (
    <signin-block
      heading="Sign in"
      intro="Welcome back to the bake sale planner."
      forgot-href="#forgot"
      signup-href="#signup"
      onsignin={(event) => console.log('signin', event.detail)}
    ></signin-block>
  );
}
Example.vue
<script setup>
import './components/zubra/signin-block.js';
const onSignin = (event) => console.log('signin', event.detail);
</script>

<template>
  <signin-block
    heading="Sign in"
    intro="Welcome back to the bake sale planner."
    forgot-href="#forgot"
    signup-href="#signup"
    @signin="onSignin"
  ></signin-block>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/signin-block.js';
</script>

<signin-block
  heading="Sign in"
  intro="Welcome back to the bake sale planner."
  forgot-href="#forgot"
  signup-href="#signup"
  onsignin={(event) => console.log('signin', event.detail)}
></signin-block>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/signin-block.js';

@Component({
  selector: 'app-signin-block-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <signin-block
      heading="Sign in"
      intro="Welcome back to the bake sale planner."
      forgot-href="#forgot"
      signup-href="#signup"
      (signin)="onSignin($event)"
    ></signin-block>
  `,
})
export class SigninBlockExample {
  onSignin(event: Event) {
    console.log('signin', (event as CustomEvent).detail);
  }
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
headingstring"Sign in"
introstring""
actionstring""
errorstring""
errorField
attribute error-field
"email" | "password" | "both""both"
busybooleanfalse
forgotHref
attribute forgot-href
string""
signupHref
attribute signup-href
string""
Events
EventWhen
signinThe form was submitted; detail is { email, password, remember }.

Size

2.2 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 19.5 KB.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour