Components
- AccordionNew
- Alert
- Alert DialogNew
- AutocompleteNew
- AvatarNew
- Badge
- Breadcrumb
- Button
- CalendarNew
- CardNew
- Checkbox
- Checkbox GroupNew
- CollapsibleNew
- ComboboxNew
- CommandNew
- Context MenuNew
- Date PickerNew
- DialogNew
- DrawerNew
- EmptyNew
- FieldNew
- FieldsetNew
- FormNew
- FrameNew
- GroupNew
- Input
- Input GroupNew
- KbdNew
- Label
- MenuNew
- MeterNew
- Number Field
- OTP FieldNew
- Pagination
- PopoverNew
- Preview CardNew
- Progress
- Radio Group
- Scroll AreaNew
- Select
- Separator
- SheetNew
- SkeletonNew
- Slider
- Spinner
- StepperNew
- Switch
- Table
- TabsNew
- Textarea
- ToastNew
- ToggleNew
- Toggle GroupNew
- ToolbarNew
- Tooltip
Input
A native input element.
import { Input } from "mako-ui/components/input";
export default function Particle() {
return <Input aria-label="Enter text" placeholder="Enter text" type="text" />;
}
Usage
import { Input } from "mako-ui/components/input"<Input />API Reference
Input
A text input with custom size options.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "default" | "lg" | number | "default" | Controls the input height. Number values are passed to the native size attribute |
unstyled | boolean | false | When true, removes the wrapper styling (border, shadow, etc.) |
Examples
For accessible labelling and validation, prefer using the Field component to wrap inputs, or the FieldControl component. See some related examples.
Small Size
import { Input } from "mako-ui/components/input";
export default function Particle() {
return (
<Input
aria-label="Enter text"
placeholder="Enter text"
size="sm"
type="text"
/>
);
}
Large Size
import { Input } from "mako-ui/components/input";
export default function Particle() {
return (
<Input
aria-label="Enter text"
placeholder="Enter text"
size="lg"
type="text"
/>
);
}
Disabled
import { Input } from "mako-ui/components/input";
export default function Particle() {
return (
<Input aria-label="Disabled" disabled placeholder="Disabled" type="text" />
);
}
File
import { Input } from "mako-ui/components/input";
export default function Particle() {
return <Input aria-label="File" type="file" />;
}
With Label
import { Input } from "mako-ui/components/input";
import { Label } from "mako-ui/components/label";
import { useId } from "react";
export default function Particle() {
const id = useId();
return (
<div className="flex flex-col items-start gap-2">
<Label htmlFor={id}>Email</Label>
<Input
aria-label="Email"
id={id}
placeholder="you@example.com"
type="email"
/>
</div>
);
}
With Button
import { Button } from "mako-ui/components/button";
import { Group } from "mako-ui/components/group";
import { Input } from "mako-ui/components/input";
export default function Particle() {
return (
<Group aria-label="Email subscription" className="gap-2">
<Input
aria-label="Email"
className="flex-1"
placeholder="you@example.com"
type="email"
/>
<div>
<Button variant="outline">Send</Button>
</div>
</Group>
);
}
Form Integration
"use client";
import { Button } from "mako-ui/components/button";
import { Field, FieldError, FieldLabel } from "mako-ui/components/field";
import { Form } from "mako-ui/components/form";
import { Input } from "mako-ui/components/input";
import type { FormEvent } from "react";
import { useState } from "react";
function stringValue(formData: FormData, name: string): string {
const value = formData.get(name);
return typeof value === "string" ? value : "";
}
export default function Particle() {
const [loading, setLoading] = useState(false);
const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
setLoading(true);
await new Promise((r) => setTimeout(r, 800));
setLoading(false);
alert(`Email: ${stringValue(formData, "email")}`);
};
return (
<Form className="flex w-full max-w-64 flex-col gap-4" onSubmit={onSubmit}>
<Field name="email">
<FieldLabel>Email</FieldLabel>
<Input placeholder="you@example.com" required type="email" />
<FieldError>Please enter a valid email.</FieldError>
</Field>
<Button loading={loading} type="submit">
Submit
</Button>
</Form>
);
}