Input

The browser's own text input in the kit's field look, named by a label above it.

import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-2">
    <Label htmlFor="input-email">Title</Label>
    <Input id="input-email" placeholder="Placeholder" type="email" />
  </div>
);

export default Example;

Usage

import { Mail01Icon } from "@hugeicons/core-free-icons";
import { Icon } from "@produkto/ui/Icon";
import { Input } from "@produkto/ui/Input";
<Input
  type="email"
  placeholder="Placeholder"
  start={<Icon icon={Mail01Icon} />}
/>

Examples

Appearances

appearance paints the field on the kit's one scale: solid, the default, soft on the grey wash, outline with only its line, and transparent with neither until it is hovered.

import { Input, type InputAppearance } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const variants: { appearance: InputAppearance; label: string }[] = [
  { appearance: "solid", label: "Solid" },
  { appearance: "soft", label: "Soft" },
  { appearance: "outline", label: "Outline" },
  { appearance: "transparent", label: "Transparent" },
];

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    {variants.map((variant) => (
      <div className="flex flex-col gap-2" key={variant.appearance}>
        <Label htmlFor={`input-appearance-${variant.appearance}`}>
          {variant.label}
        </Label>
        <Input
          id={`input-appearance-${variant.appearance}`}
          placeholder="Placeholder"
          appearance={variant.appearance}
        />
      </div>
    ))}
  </div>
);

export default Example;

Sizes

size sets its height: sm 32px, base 40px (the default) or lg 48px, a Button's height at the same size, the large one written at 16px on a phone.

import { Input, type InputSize } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const variants: { size: InputSize; label: string }[] = [
  { size: "sm", label: "Small" },
  { size: "base", label: "Base" },
  { size: "lg", label: "Large" },
];

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    {variants.map((variant) => (
      <div className="flex flex-col gap-2" key={variant.size}>
        <Label htmlFor={`input-size-${variant.size}`}>{variant.label}</Label>
        <Input
          id={`input-size-${variant.size}`}
          placeholder="Placeholder"
          size={variant.size}
        />
      </div>
    ))}
  </div>
);

export default Example;

Border radius

borderRadius sets its corners on the kit's one scale: none, xs 4px, sm 6px, base 8px (the default), lg 12px, xl 16px, or full to round it.

import { Input, type InputBorderRadius } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const variants: { borderRadius: InputBorderRadius; label: string }[] = [
  { borderRadius: "none", label: "None" },
  { borderRadius: "xs", label: "xs" },
  { borderRadius: "sm", label: "sm" },
  { borderRadius: "base", label: "base" },
  { borderRadius: "lg", label: "lg" },
  { borderRadius: "xl", label: "xl" },
  { borderRadius: "full", label: "full" },
];

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    {variants.map((variant) => (
      <div className="flex flex-col gap-2" key={variant.borderRadius}>
        <Label htmlFor={`input-radius-${variant.borderRadius}`}>
          {variant.label}
        </Label>
        <Input
          id={`input-radius-${variant.borderRadius}`}
          placeholder="Placeholder"
          borderRadius={variant.borderRadius}
        />
      </div>
    ))}
  </div>
);

export default Example;

With icon

start and end set an Icon inside the field, before the text or after it.

import { Search01Icon, Tick02Icon } from "@hugeicons/core-free-icons";
import { Icon } from "@produkto/ui/Icon";
import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-icon-start">Label</Label>
      <Input
        id="input-icon-start"
        placeholder="Placeholder"
        start={<Icon icon={Search01Icon} />}
      />
    </div>
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-icon-end">Label</Label>
      <Input
        end={<Icon icon={Tick02Icon} />}
        id="input-icon-end"
        placeholder="Placeholder"
      />
    </div>
  </div>
);

export default Example;

Text

Words in start or end sit around the value without being part of it, such as a prefix or a domain.

https://
.com
import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-text-start">Label</Label>
      <Input id="input-text-start" placeholder="Placeholder" start="https://" />
    </div>
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-text-end">Label</Label>
      <Input end=".com" id="input-text-end" placeholder="Placeholder" />
    </div>
  </div>
);

export default Example;

Button

A small Button in start or end sits inside the field, its corners one step inside the field's, holding an icon or words.

import { Add01Icon } from "@hugeicons/core-free-icons";
import { Button } from "@produkto/ui/Button";
import { Icon } from "@produkto/ui/Icon";
import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-button-start">Label</Label>
      <Input
        id="input-button-start"
        placeholder="Placeholder"
        start={
          <Button aria-label="Button" size="sm">
            <Icon icon={Add01Icon} />
          </Button>
        }
      />
    </div>
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-button-end">Label</Label>
      <Input
        end={<Button size="sm">Button</Button>}
        id="input-button-end"
        placeholder="Placeholder"
      />
    </div>
  </div>
);

export default Example;

Select

A Select in start picks what the text beside it is in, its trigger drawn like the field's buttons and its list without a search.

import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";
import {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectTrigger,
} from "@produkto/ui/Select";
import { useState } from "react";

const items: string[] = ["Item 1", "Item 2", "Item 3"];

const Example = () => {
  const [item, setItem] = useState(items[0]);
  return (
    <div className="flex w-full max-w-xs flex-col gap-2">
      <Label htmlFor="input-select">Label</Label>
      <Input
        id="input-select"
        placeholder="Placeholder"
        start={
          <Select value={item} onValueChange={setItem}>
            <SelectTrigger aria-label="Label" size="sm">
              {item}
            </SelectTrigger>
            <SelectContent>
              <SelectGroup>
                {items.map((each) => (
                  <SelectItem key={each} value={each}>
                    {each}
                  </SelectItem>
                ))}
              </SelectGroup>
            </SelectContent>
          </Select>
        }
      />
    </div>
  );
};

export default Example;

Chips

chips holds what was picked as chips before the text being typed, each removed by its X through onChipRemove; Enter adds the text as another.

Item 1Item 2
import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";
import { useState } from "react";

const Example = () => {
  const [chips, setChips] = useState(["Item 1", "Item 2"]);
  const [draft, setDraft] = useState("");
  return (
    <div className="flex w-full max-w-sm flex-col gap-2">
      <Label htmlFor="input-chips">Label</Label>
      <Input
        chips={chips}
        id="input-chips"
        onChange={(event) => setDraft(event.target.value)}
        onChipRemove={(chip) => setChips(chips.filter((each) => each !== chip))}
        onKeyDown={(event) => {
          const text = draft.trim();
          if (event.key !== "Enter" || !text || chips.includes(text)) return;
          event.preventDefault();
          setChips([...chips, text]);
          setDraft("");
        }}
        placeholder="Placeholder"
        value={draft}
      />
    </div>
  );
};

export default Example;

Clearable

clearable shows an X at its end once it holds text, which empties it and gives it the focus back; by default a field has none.

import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-clearable-off">Label</Label>
      <Input
        defaultValue="Content goes here."
        id="input-clearable-off"
        placeholder="Placeholder"
      />
    </div>
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-clearable">Label</Label>
      <Input
        clearable
        defaultValue="Content goes here."
        id="input-clearable"
        placeholder="Placeholder"
      />
    </div>
  </div>
);

export default Example;

Password

type="password" puts an eye at the end of the field that shows or hides what was typed, and the field hides it again when its form is sent.

import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-2">
    <Label htmlFor="input-password">Label</Label>
    <Input id="input-password" placeholder="Placeholder" type="password" />
  </div>
);

export default Example;

Disabled

disabled dims the input and stops it taking text, beside one as it is by default.

import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-enabled">Label</Label>
      <Input defaultValue="Content goes here." id="input-enabled" />
    </div>
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-disabled">Label</Label>
      <Input defaultValue="Content goes here." disabled id="input-disabled" />
    </div>
  </div>
);

export default Example;

Invalid

error writes what is wrong under the input, turns its border to the destructive colour and describes it to screen readers, beside one without an error.

import { Input } from "@produkto/ui/Input";
import { Label } from "@produkto/ui/Label";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-valid">Label</Label>
      <Input id="input-valid" placeholder="Placeholder" />
    </div>
    <div className="flex flex-col gap-2">
      <Label htmlFor="input-error">Label</Label>
      <Input error="Description" id="input-error" placeholder="Placeholder" />
    </div>
  </div>
);

export default Example;

API Reference

Input

InputProps · components/Input/Input.types.ts
PropTypeDefault
startReactNode-
endReactNode-
chipsstring[]-
onChipRemove(chip: string) => void-
appearanceInputAppearance"solid" | "soft" | "outline" | "transparent"-
sizeInputSize"sm" | "base" | "lg"-
borderRadiusInputBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl" | "full"-
clearableboolean-
errorReactNode-

It also takes the props of <input>.