Forms
Input
A neutral text control with clear placeholder, focus, and icon handling.import { Input } from "@hyzrui/core";
export function Example() {
return <Input placeholder="Name" />;
}Installation
Install the primitive source, then keep editing it inside your app. The command names the component file you want copied.
pnpm dlx hyzrui add inputUsage
Import the component from the generated source folder and compose it with normal React props.
import { Input } from "@hyzrui/core";<Input className="my-input" />Customization
Every primitive accepts local props and class names, then inherits design tokens from HyzrThemeProvider . Copy the file, keep the markup, and tune the CSS until it matches your product.
--hui-radiusControls the default corner system for buttons, inputs, cards, overlays, and nested surfaces.--hui-foregroundControls the page and component text colors. Dark mode uses the same component source with different tokens.--hui-surfaceControls card, dialog, popover, and input surfaces.--hui-borderControls separators, input strokes, card outlines, and menu edges.--hui-primaryControls the main action color and the matching foreground color for solid controls.--hui-font-familyControls the font stack used by every primitive inside the provider.--hui-control-font-sizeControls the default font size for buttons, inputs, selects, tabs, command rows, and menu triggers.--hui-font-weight-controlControls the default weight of buttons, tabs, menus, badges, and compact actions.--hui-control-heightControls the default field and trigger height across forms and navigation.--hui-button-heightControls button height independently from form fields.--hui-button-paddingControls horizontal button spacing without changing the text size.--hui-card-paddingControls card, dialog, sheet, drawer, and panel interior spacing.--hui-border-widthControls default edge width for controls, cards, tables, and floating panels.--hui-focus-widthControls keyboard focus outline thickness.--hui-transition-durationControls shared hover timing for controls and surfaces.--hui-hover-liftControls subtle hover lift for raised styles.--hui-overlayControls dialog, sheet, drawer, and command overlay strength.--hui-floating-offsetControls menu, command, popover, and hover-card distance from the trigger.import { defineHyzrTheme } from "@hyzrui/core";
export const theme = defineHyzrTheme({
id: "product",
density: "comfortable",
radius: 10,
shadow: 0.08,
colors: {
background: "#fbfbfc",
foreground: "#09090b",
surface: "#ffffff",
border: "#e4e4e7",
primary: "#18181b",
primaryForeground: "#ffffff",
},
typography: {
controlSize: 14,
controlWeight: 500,
headingWeight: 680,
},
sizing: {
controlHeight: 38,
buttonHeight: 34,
buttonPadding: 14,
cardPadding: 18,
},
borders: {
radius: 10,
radiusSm: 7,
radiusLg: 16,
width: 1,
focusWidth: 2,
},
motion: {
duration: 150,
hoverLift: 0,
hoverMix: 5,
},
});See the customization guide for the full theme shape, style presets, scoped CSS overrides, and source-edit workflow.
Examples
These examples show the same primitive in realistic combinations and states.
With icons
Leading icons help users identify the field purpose quickly; trailing icons add secondary affordances.
import { Mail, Search, Eye, Lock } from "lucide-react";
import { Input } from "@hyzrui/core";
export function InputWithIcons() {
return (
<div style={{ display: "grid", gap: 10, maxWidth: 320 }}>
<Input leadingIcon={<Mail size={16} />} placeholder="Email address" />
<Input leadingIcon={<Search size={16} />} placeholder="Search components..." />
<Input leadingIcon={<Lock size={16} />} trailingIcon={<Eye size={16} />} placeholder="Password" type="password" />
</div>
);
}Validation states
Use Field's hint for guidance before interaction and error for inline validation feedback.
Only letters, numbers, and underscores.
This email is already registered.
import { Input, Field } from "@hyzrui/core";
export function InputValidation() {
return (
<div style={{ display: "grid", gap: 14, maxWidth: 320 }}>
<Field label="Username" hint="Only letters, numbers, and underscores.">
<Input defaultValue="hyzr1" />
</Field>
<Field label="Email" error="This email is already registered.">
<Input defaultValue="taken@example.com" className="input-error" />
</Field>
</div>
);
}Input groups
InputGroup adds text add-ons without breaking the field's visual alignment.
import { Input, InputGroup, Field } from "@hyzrui/core";
export function InputGroupExamples() {
return (
<div style={{ display: "grid", gap: 12, maxWidth: 320 }}>
<Field label="Transfer amount">
<InputGroup leading="$" trailing="USD">
<Input defaultValue="1,200.00" />
</InputGroup>
</Field>
<Field label="Domain">
<InputGroup leading="https://" trailing=".com">
<Input defaultValue="myapp" />
</InputGroup>
</Field>
</div>
);
}API Reference
Props are intentionally small. For deeper changes, edit the component source file directly.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Adds classes to the copied component without replacing the default structure. |
children | React.ReactNode | - | The rendered content for compound or wrapper components. |
...props | HTMLAttributes | - | Forwards native element props such as id, aria attributes, and event handlers. |
leadingIcon | React.ReactNode | - | Optional icon before input text. |
trailingIcon | React.ReactNode | - | Optional icon after input text. |
placeholder | string | - | Native input placeholder. |