A component for collecting data input.
Enter your full name
import { Input, InputWrapper } from "#/ui/components/Input"
<InputWrapper label="Name">
<Input placeholder="Dan Spratling" />
</InputWrapper>
The Input
component provides some base styling to the regular input
element, but you can pass any other props to it that you would normally pass to an input
element too.
The InputWrapper
goes around your Input
to provide additional associated elements easily like labels & hints, but it’s totally optional if you want to use an Input separate from your labels and roll-your-own.
<InputWrapper label="Name">
<Input placeholder="Dan Spratling" />
</InputWrapper>
<div className="w-full flex items-center">
<label htmlFor="example-input" className="w-1/3">
Custom Label
</label>
<Input id="example-input" placeholder="Dan Spratling" />
</div>
You can pass a hint to the InputWrapper
to provide additional context to the user.
What do you call yourself?
<InputWrapper label="Name" hint="required">
<Input placeholder="Dan Spratling" />
</InputWrapper>
Passing an error to the InputWrapper
and Input
will display error styles. If a hint exists, it will be replaced with the error.
Your name is required
<InputWrapper label="Name" hint="required" error="Your name is required">
<Input placeholder="Dan Spratling" error={true} />
</InputWrapper>
You can pass a InputLeading
element to the InputWrapper
to provide additional context to the user. This can accept any element as a child, which you can style yourself, but there are a few presets to help you get started.
<InputWrapper label="Name">
<InputLeading type="icon">
<Mail01Icon />
</InputLeading>
<Input placeholder="hello@skyward.digital" className="pl-10" />
</InputWrapper>
<InputWrapper label="URL">
<InputLeading type="text">https://</InputLeading>
<Input placeholder="skyward.digital" className="rounded-l-none" />
</InputWrapper>
Similar to the leading elements, this can accept children but has a few presets ready to go.
<InputWrapper label="Name">
<Input placeholder="hello@skyward.digital" />
<InputTrailing type="icon">
<Mail01Icon />
</InputTrailing>
</InputWrapper>
<InputWrapper label="URL">
<Input placeholder="skyward.digital" className="rounded-r-none" />
<InputTrailing type="text">/blog</InputTrailing>
</InputWrapper>
You can customise the input however you’d like by passing predefined or custom leading/trailing components within the slots. You can also style these components to match the input if necessary.
required
<InputWrapper label="URL" hint="required" className="w-full max-w-xl">
<InputLeading type="text">https://</InputLeading>
<Input placeholder="skyward.digital" className="rounded-none" />
<InputTrailing>
<Button variant="outline" className="rounded-l-none -ml-px border-gray-300 flex-none">
Copy
<Copy06Icon className="size-4" />
</Button>
</InputTrailing>
<Button variant="primary" size="md" className="flex-none ml-4">
<span>Save</span>
</Button>
</InputWrapper>