DOCS
v0.4

Components / Input

Input

Text input with floating label, prefix/suffix slots, clear button, validation states, and two sizes (md/lg).

formsv0.1.0

Playground

Examples

Floating labels
<cg-stack gap="sm" style="max-width: 320px;"><cg-input label="Full Name" placeholder="John Doe"></cg-input><cg-input label="Email" type="email" placeholder="you@example.com" value="john@example.com"></cg-input><cg-input label="Password" type="password"></cg-input></cg-stack>
Sizes
<cg-stack gap="sm" style="max-width: 320px;"><cg-input label="Medium" size="md" placeholder="md (default)"></cg-input><cg-input label="Large" size="lg" placeholder="lg"></cg-input></cg-stack>
States
<cg-stack gap="sm" style="max-width: 320px;"><cg-input label="Error" error helper="This field is required" value="bad@"></cg-input><cg-input label="Success" success helper="Looks good!" value="john@example.com"></cg-input><cg-input label="Disabled" disabled value="Cannot edit"></cg-input><cg-input label="Readonly" readonly value="Read only value"></cg-input><cg-input label="Loading" loading value="Validating..."></cg-input></cg-stack>
Clearable + counter
<cg-input label="Bio" clearable maxlength="100" placeholder="Tell us about yourself" value="Hello world" style="max-width: 320px;"></cg-input>

Import

import { CgInput } from '@cognivo/components';
// Or tree-shake: import '@cognivo/components/cg-input';

Per-component imports ship only that component (~8 kB gzip).

API Reference

PropTypeDefaultDescription
labelstring""Floating label text — shrinks and rises on focus
valuestring""Input value
placeholderstringPlaceholder text (shown when label is floated)
type"text" | "email" | "password" | "number" | "url" | "search" | "tel""text"Input type
size"md" | "lg""md"Input size — md (48px), lg (56px)
rounded"none" | "sm" | "md" | "lg""lg"Border radius — sm (8px), md (12px), lg (16px, default)
errorbooleanfalseError state — red border and focus ring
successbooleanfalseSuccess state — green border and focus ring
loadingbooleanfalseLoading state — shows spinner, disables input
disabledbooleanfalseDisabled state
readonlybooleanfalseReadonly state — dashed border
clearablebooleanfalseShow clear button when value is non-empty
helperstringHelper text below the input
maxlengthnumber0Max character count (shows counter when > 0)

Events

EventDetailDescription
cg-input{value: string}On every input change
cg-clear{}When clear button is clicked