Input
Input example: a single-line text field with a soft filled background, rounded pill shape and file-input styling. Includes focus ring, disabled and invalid states.
pnpm dlx shadcn add @01orbital/inputimport * as React from "react"
import { Input as InputPrimitive } from "@base-ui/react/input"
import { cn } from "cn"
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
<InputPrimitive
type={type}
data-slot="input"
className={cn(
"h-9 w-full min-w-0 rounded-3xl border border-transparent bg-input/50 px-3 py-1 text-base transition-[color,box-shadow,background-color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
className
)}
{...props}
/>
)
}
export { Input }
import { Input } from "@/components/ui/input"
// The copy: change text here, not in the markup.
const COPY = {
ariaLabel: "Search blocks",
placeholder: "Search blocks…",
} as const
/** Input with a placeholder and an accessible name. */
export default function InputDemo() {
return (
<Input
className="max-w-sm"
aria-label={COPY.ariaLabel}
placeholder={COPY.placeholder}
/>
)
}
Examples
Email and Password Sign Ininput-login-email-password-01
Classic sign-in card with email, password with show/hide toggle, keep-me-signed-in and a forgot link.
pnpm dlx shadcn add @01orbital/input-login-email-password-01"use client"
import { useState, type FormEvent } from "react"
import { EyeIcon, EyeSlashIcon } from "@phosphor-icons/react"
import { Title } from "@/components/title/title"
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card"
import { Checkbox } from "@/components/ui/checkbox"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
const COPY = {
title: "Welcome back",
body: "Sign in to your Orbcore account to pick up where you left off.",
email: "Email",
emailPlaceholder: "you@company.com",
password: "Password",
forgot: "Forgot password?",
remember: "Keep me signed in",
submit: "Sign in",
busy: "Signing in",
show: "Show password",
hide: "Hide password",
footer: "New to Orbcore?",
footerLink: "Create an account",
} as const
export default function LoginEmailPassword01() {
const [visible, setVisible] = useState(false)
const [busy, setBusy] = useState(false)
function submit(event: FormEvent) {
event.preventDefault()
setBusy(true)
window.setTimeout(() => setBusy(false), 900)
}
return (
<div className="flex min-h-[640px] w-full items-center justify-center bg-muted/40 px-4 py-12">
<Card className="w-full max-w-sm">
<CardContent className="px-6 sm:px-8">
<form onSubmit={submit} className="flex flex-col gap-6">
<div className="flex flex-col gap-1.5">
<Title render={<h2 />} className="font-semibold">
{COPY.title}
</Title>
<p className="text-sm text-muted-foreground">{COPY.body}</p>
</div>
<div className="flex flex-col gap-2">
<Label htmlFor="ep-email">{COPY.email}</Label>
<Input
id="ep-email"
type="email"
autoComplete="email"
placeholder={COPY.emailPlaceholder}
required
/>
</div>
<div className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<Label htmlFor="ep-password">{COPY.password}</Label>
<a
href="#"
className="text-sm text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
>
{COPY.forgot}
</a>
</div>
<div className="relative">
<Input
id="ep-password"
type={visible ? "text" : "password"}
autoComplete="current-password"
className="pr-11"
required
/>
<Button
type="button"
variant="ghost"
size="icon-sm"
className="absolute top-1/2 right-1 -translate-y-1/2"
aria-label={visible ? COPY.hide : COPY.show}
aria-pressed={visible}
onClick={() => setVisible((v) => !v)}
>
{visible ? <EyeSlashIcon /> : <EyeIcon />}
</Button>
</div>
</div>
<div className="flex items-center gap-2">
<Checkbox id="ep-remember" defaultChecked />
<Label htmlFor="ep-remember" className="text-sm font-normal">
{COPY.remember}
</Label>
</div>
<Button type="submit" size="lg" className="w-full" disabled={busy}>
{busy ? COPY.busy : COPY.submit}
</Button>
<p className="text-center text-sm text-muted-foreground">
{COPY.footer}{" "}
<a
href="#"
className="font-medium text-foreground underline-offset-4 hover:underline"
>
{COPY.footerLink}
</a>
</p>
</form>
</CardContent>
</Card>
</div>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: the card, panel or column that holds it is the
// measure. text-pretty keeps a wrapped title from ending on one word.
/**
* The title of a card, panel or list group, rendered as an `<h3>` in the body
* font: 18px with a 28px line, 20px from the `sm` breakpoint, medium weight.
* One size, no props beyond the element's own; pass `render` to use another
* heading level. Inside a stock `Card`, use `CardTitle`; a section's heading
* is `Subheading` and a page's headline is `Heading`.
*/
function Title({
className,
render,
...props
}: useRender.ComponentProps<"h3">) {
return useRender({
defaultTagName: "h3",
render,
state: { slot: "title" },
props: mergeProps<"h3">(
{
className: cn(
"text-lg/7 font-medium tracking-tight text-pretty sm:text-xl/7",
className
),
},
props
),
})
}
export { Title }
Magic Link Sign Ininput-login-magic-link-01
Passwordless sign-in that emails a one-time link, then swaps to a check-your-inbox confirmation with resend.
pnpm dlx shadcn add @01orbital/input-login-magic-link-01"use client"
import { useEffect, useRef, useState, type FormEvent } from "react"
import {
ArrowLeftIcon,
EnvelopeSimpleIcon,
MagicWandIcon,
} from "@phosphor-icons/react"
import { Title } from "@/components/title/title"
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
const COPY = {
title: "Sign in with a link",
body: "No password needed. We’ll email you a one-time link that signs you in.",
email: "Work email",
emailPlaceholder: "you@company.com",
submit: "Email me a link",
sentTitle: "Check your inbox",
sentBody: "We sent a sign-in link to",
sentNote: "The link expires in 15 minutes and works once.",
resend: "Send it again",
resent: "Sent again",
change: "Use a different email",
password: "Prefer a password?",
passwordLink: "Sign in with password",
} as const
export default function LoginMagicLink01() {
const [email, setEmail] = useState("")
const [sent, setSent] = useState(false)
const [resent, setResent] = useState(false)
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
useEffect(
() => () => {
if (timer.current) clearTimeout(timer.current)
},
[]
)
function resend() {
setResent(true)
if (timer.current) clearTimeout(timer.current)
timer.current = setTimeout(() => setResent(false), 5000)
}
function submit(event: FormEvent) {
event.preventDefault()
if (email.trim()) setSent(true)
}
return (
<div className="flex min-h-[600px] w-full items-center justify-center bg-muted/40 px-4 py-12">
<Card className="w-full max-w-sm">
<CardContent className="px-6 sm:px-8">
{sent ? (
<div className="flex flex-col items-center gap-6 text-center">
<span className="flex size-12 items-center justify-center rounded-full bg-muted">
<EnvelopeSimpleIcon className="size-6" weight="duotone" />
</span>
<div className="flex flex-col gap-1.5">
<Title render={<h2 />} className="font-semibold">
{COPY.sentTitle}
</Title>
<p className="text-sm text-muted-foreground">
{COPY.sentBody}{" "}
<span className="font-medium text-foreground">{email}</span>.
</p>
<p className="text-sm text-muted-foreground">{COPY.sentNote}</p>
</div>
<div className="flex w-full flex-col gap-2">
<Button
type="button"
variant="outline"
size="lg"
className="w-full"
disabled={resent}
onClick={resend}
>
<span aria-live="polite">
{resent ? COPY.resent : COPY.resend}
</span>
</Button>
<Button
type="button"
variant="ghost"
onClick={() => setSent(false)}
>
<ArrowLeftIcon data-icon="inline-start" />
{COPY.change}
</Button>
</div>
</div>
) : (
<form onSubmit={submit} className="flex flex-col gap-6">
<div className="flex flex-col gap-2">
<span className="flex size-10 items-center justify-center rounded-2xl bg-muted">
<MagicWandIcon className="size-5" weight="duotone" />
</span>
<Title render={<h2 />} className="font-semibold">
{COPY.title}
</Title>
<p className="text-sm text-muted-foreground">{COPY.body}</p>
</div>
<div className="flex flex-col gap-2">
<Label htmlFor="ml-email">{COPY.email}</Label>
<Input
id="ml-email"
type="email"
autoComplete="email"
placeholder={COPY.emailPlaceholder}
value={email}
onChange={(event) => setEmail(event.target.value)}
required
/>
</div>
<Button type="submit" size="lg" className="w-full">
{COPY.submit}
</Button>
<p className="text-center text-sm text-muted-foreground">
{COPY.password}{" "}
<a
href="#"
className="font-medium text-foreground underline-offset-4 hover:underline"
>
{COPY.passwordLink}
</a>
</p>
</form>
)}
</CardContent>
</Card>
</div>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: the card, panel or column that holds it is the
// measure. text-pretty keeps a wrapped title from ending on one word.
/**
* The title of a card, panel or list group, rendered as an `<h3>` in the body
* font: 18px with a 28px line, 20px from the `sm` breakpoint, medium weight.
* One size, no props beyond the element's own; pass `render` to use another
* heading level. Inside a stock `Card`, use `CardTitle`; a section's heading
* is `Subheading` and a page's headline is `Heading`.
*/
function Title({
className,
render,
...props
}: useRender.ComponentProps<"h3">) {
return useRender({
defaultTagName: "h3",
render,
state: { slot: "title" },
props: mergeProps<"h3">(
{
className: cn(
"text-lg/7 font-medium tracking-tight text-pretty sm:text-xl/7",
className
),
},
props
),
})
}
export { Title }
Passkey Sign Ininput-login-passkey-01
A welcome-back card listing registered passkeys by device, with a simulated waiting and verified sign-in flow.
pnpm dlx shadcn add @01orbital/input-login-passkey-01"use client"
import { useState, type FormEvent } from "react"
import {
CheckCircleIcon,
DeviceMobileIcon,
FingerprintIcon,
KeyIcon,
LaptopIcon,
UsbIcon,
} from "@phosphor-icons/react"
import { cn } from "cn"
import { Title } from "@/components/title/title"
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import { Separator } from "@/components/ui/separator"
import { Spinner } from "@/components/ui/spinner"
const COPY = {
title: (name: string | null) =>
name ? `Welcome back, ${name}` : "Sign in to your account",
body: "Sign in with a passkey. No password to type, nothing to phish.",
submit: "Continue with passkey",
waiting: "Waiting for your device",
success: "Verified. Signing you in",
or: "Or",
password: "Use a password instead",
other: (name: string) => `Not ${name}? Switch account`,
passkeyInstead: "Use a passkey instead",
email: "Email",
emailPlaceholder: "you@company.com",
passwordLabel: "Password",
signIn: "Sign in",
next: "Continue",
passwordBody: "Enter your password to sign in.",
emailBody: "Enter the email for the account you want to use.",
note: "Your fingerprint, face or screen lock never leaves your device.",
} as const
const PASSKEYS = [
{
id: "mac",
name: "MacBook Pro",
detail: "Touch ID · used today",
icon: LaptopIcon,
},
{
id: "phone",
name: "iPhone 16",
detail: "Face ID · used 3 days ago",
icon: DeviceMobileIcon,
},
{
id: "key",
name: "YubiKey 5C",
detail: "Security key · used last month",
icon: UsbIcon,
},
] as const
const ACCOUNT = { name: "Maya", email: "maya@orbcore.co" } as const
type Status = "idle" | "waiting" | "done"
type Mode = "passkey" | "password" | "email"
export default function LoginPasskeySignIn01() {
const [selected, setSelected] = useState<string>(PASSKEYS[0].id)
const [status, setStatus] = useState<Status>("idle")
const [mode, setMode] = useState<Mode>("passkey")
const [name, setName] = useState<string | null>(ACCOUNT.name)
const [email, setEmail] = useState<string>(ACCOUNT.email)
function switchAccount() {
setName(null)
setEmail("")
setStatus("idle")
setMode("email")
}
function submitForm(event: FormEvent<HTMLFormElement>) {
event.preventDefault()
if (mode === "email") {
setMode("password")
return
}
setStatus("done")
}
function start() {
setStatus("waiting")
window.setTimeout(() => setStatus("done"), 1600)
}
return (
<div className="flex min-h-[640px] w-full items-center justify-center bg-muted/40 px-4 py-12">
<Card className="w-full max-w-sm">
<CardContent className="flex flex-col items-center gap-6 px-6 text-center sm:px-8">
<span
className={cn(
"flex size-16 items-center justify-center rounded-full bg-muted transition-colors",
status === "done" && "bg-primary text-primary-foreground"
)}
>
{status === "done" ? (
<CheckCircleIcon className="size-8" weight="fill" />
) : (
<FingerprintIcon className="size-8" weight="duotone" />
)}
</span>
<div className="flex flex-col gap-1.5">
<Title render={<h2 />}>{COPY.title(name)}</Title>
<p className="text-sm text-muted-foreground" aria-live="polite">
{status === "done"
? COPY.success
: mode === "passkey"
? COPY.body
: mode === "password"
? COPY.passwordBody
: COPY.emailBody}
</p>
</div>
{mode === "passkey" ? (
<>
<ul
className="flex w-full flex-col gap-2 text-left"
aria-label="Your passkeys"
>
{PASSKEYS.map((key) => {
const active = key.id === selected
return (
<li key={key.id}>
<button
type="button"
disabled={status !== "idle"}
onClick={() => setSelected(key.id)}
aria-pressed={active}
className={cn(
"flex w-full items-center gap-3 rounded-2xl border px-3.5 py-3 transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-60",
active
? "border-foreground/30 bg-muted"
: "hover:bg-muted/50"
)}
>
<key.icon
className="size-5 shrink-0"
weight="duotone"
/>
<span className="min-w-0 flex-1">
<span className="block truncate text-sm font-medium">
{key.name}
</span>
<span className="block truncate text-xs text-muted-foreground">
{key.detail}
</span>
</span>
{active ? (
<CheckCircleIcon
className="size-5 shrink-0"
weight="fill"
/>
) : null}
</button>
</li>
)
})}
</ul>
<Button
size="lg"
className="w-full"
disabled={status !== "idle"}
onClick={start}
>
{status === "waiting" ? (
<>
<Spinner data-icon="inline-start" />
{COPY.waiting}
</>
) : status === "done" ? (
COPY.success
) : (
<>
<KeyIcon data-icon="inline-start" />
{COPY.submit}
</>
)}
</Button>
</>
) : (
<form className="w-full text-left" onSubmit={submitForm}>
<FieldGroup>
<Field>
<FieldLabel htmlFor="passkey-email">{COPY.email}</FieldLabel>
<Input
id="passkey-email"
type="email"
required
autoComplete="username"
placeholder={COPY.emailPlaceholder}
value={email}
onChange={(event) => setEmail(event.target.value)}
disabled={status === "done"}
/>
</Field>
{mode === "password" ? (
<Field>
<FieldLabel htmlFor="passkey-password">
{COPY.passwordLabel}
</FieldLabel>
<Input
id="passkey-password"
type="password"
required
autoComplete="current-password"
disabled={status === "done"}
/>
</Field>
) : null}
<Button
type="submit"
size="lg"
className="w-full"
disabled={status === "done"}
>
{status === "done"
? COPY.success
: mode === "password"
? COPY.signIn
: COPY.next}
</Button>
</FieldGroup>
</form>
)}
<div className="flex w-full items-center gap-3 text-xs text-muted-foreground">
<Separator className="flex-1" />
{COPY.or}
<Separator className="flex-1" />
</div>
<div className="flex flex-col items-center gap-1">
{mode === "passkey" ? (
<Button
variant="ghost"
size="sm"
onClick={() => {
setStatus("idle")
setMode("password")
}}
>
{COPY.password}
</Button>
) : mode === "password" ? (
<Button
variant="ghost"
size="sm"
onClick={() => {
setStatus("idle")
setName(ACCOUNT.name)
setEmail(ACCOUNT.email)
setMode("passkey")
}}
>
{COPY.passkeyInstead}
</Button>
) : null}
{name ? (
<Button variant="link" size="sm" onClick={switchAccount}>
{COPY.other(name)}
</Button>
) : null}
</div>
<p className="text-xs text-muted-foreground">{COPY.note}</p>
</CardContent>
</Card>
</div>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: the card, panel or column that holds it is the
// measure. text-pretty keeps a wrapped title from ending on one word.
/**
* The title of a card, panel or list group, rendered as an `<h3>` in the body
* font: 18px with a 28px line, 20px from the `sm` breakpoint, medium weight.
* One size, no props beyond the element's own; pass `render` to use another
* heading level. Inside a stock `Card`, use `CardTitle`; a section's heading
* is `Subheading` and a page's headline is `Heading`.
*/
function Title({
className,
render,
...props
}: useRender.ComponentProps<"h3">) {
return useRender({
defaultTagName: "h3",
render,
state: { slot: "title" },
props: mergeProps<"h3">(
{
className: cn(
"text-lg/7 font-medium tracking-tight text-pretty sm:text-xl/7",
className
),
},
props
),
})
}
export { Title }
Dependencies
npm: @base-ui/react, cn. The CLI installs them for you. cn merges Tailwind class names, in place of clsx and tailwind-merge.
Used in blocks
23 blocks are built with Input; the first 12: