Input
A native <input> with the Glaceon control tokens. The invalid prop swaps the border to the destructive token and sets aria-invalid for assistive tech. The visible error message belongs to the form-field wrapper, not here.
Interactive Preview
Section titled “Interactive Preview”React Inputlive
Svelte Inputlive
Solid Inputlive
import { Input } from "@/components/ui/input";
<Input placeholder="Full name" /><Input invalid placeholder="email@example.com" aria-describedby="email-error" /><script lang="ts"> import Input from "@/components/ui/input.svelte";</script>
<Input placeholder="Full name" /><Input invalid placeholder="email@example.com" aria-describedby="email-error" />import { Input } from "@/components/ui/input";
<Input placeholder="Full name" /><Input invalid placeholder="email@example.com" aria-describedby="email-error" />Installation
Section titled “Installation”npx @glaceon/cli add input --framework react # or svelte, solidInput is CSS-only. No Zag machine is needed.
bun add clsx tailwind-mergeThen copy the source for your framework:
import type { InputHTMLAttributes } from "react"import { cn } from "@/lib/cn"
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> { /** Marks the field invalid: red border plus aria-invalid. The error message itself is the wrapper's job. */ invalid?: boolean}
const base = "h-11 w-full rounded-md border bg-surface px-3 text-sm text-ink transition-colors placeholder:text-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-action focus-visible:ring-offset-2 ring-offset-surface disabled:cursor-not-allowed disabled:opacity-50"
export function Input({ invalid = false, className, type = "text", ...props }: InputProps) { return ( <input type={type} aria-invalid={invalid || undefined} {...props} className={cn(base, invalid ? "border-danger" : "border-line", className)} /> )}<script lang="ts"> import { cn } from "@/lib/cn"
interface Props { invalid?: boolean type?: string class?: string [key: string]: unknown }
const { invalid = false, type = "text", class: className, ...rest }: Props = $props()
const base = "h-11 w-full rounded-md border bg-surface px-3 text-sm text-ink transition-colors placeholder:text-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-action focus-visible:ring-offset-2 ring-offset-surface disabled:cursor-not-allowed disabled:opacity-50"</script>
<input {type} aria-invalid={invalid || undefined} {...rest} class={cn(base, invalid ? "border-danger" : "border-line", className)}/>import { splitProps, type JSX } from "solid-js"import { cn } from "@/lib/cn"
export interface InputProps extends JSX.InputHTMLAttributes<HTMLInputElement> { /** Marks the field invalid: red border plus aria-invalid. The error message itself is the wrapper's job. */ invalid?: boolean}
const base = "h-11 w-full rounded-md border bg-surface px-3 text-sm text-ink transition-colors placeholder:text-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-action focus-visible:ring-offset-2 ring-offset-surface disabled:cursor-not-allowed disabled:opacity-50"
export function Input(props: InputProps) { const [local, rest] = splitProps(props, ["invalid", "class"]) return ( <input type={rest.type ?? "text"} aria-invalid={local.invalid || undefined} {...rest} class={cn(base, local.invalid ? "border-danger" : "border-line", local.class)} /> )}States
Section titled “States”| State | Selector | Applied styling |
|---|---|---|
| Default | base | 1px --line border on --surface. |
| Invalid | [aria-invalid] |
Border switches to --danger. The invalid prop also sets aria-invalid so the state is announced, not just coloured. |
| Placeholder | ::placeholder |
--muted. |
| Focus | :focus-visible |
2px --action ring with offset. |
| Disabled | [disabled] |
cursor-not-allowed and 50% opacity. |
API Reference (Props)
Section titled “API Reference (Props)”| Prop | Type | Default | Description |
|---|---|---|---|
invalid |
boolean |
false |
Red border plus aria-invalid="true". |
type |
string |
"text" |
Native input type. |
value |
string |
undefined |
Native value. Uncontrolled unless you handle onChange. |
disabled |
boolean |
false |
Native disabled state. |
placeholder |
string |
undefined |
Native placeholder text. |
class / className |
string |
undefined |
Extra classes, appended last. |
All other native <input> attributes pass through unchanged.