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
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
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
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
<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
<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>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>
);
}<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('-') } } }) --><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>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
| Property | Type | Default |
|---|---|---|
heading | string | "Sign in" |
intro | string | "" |
action | string | "" |
error | string | "" |
errorFieldattribute error-field | "email" | "password" | "both" | "both" |
busy | boolean | false |
forgotHrefattribute forgot-href | string | "" |
signupHrefattribute signup-href | string | "" |
| Event | When |
|---|---|
signin | The 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.