Primitives
Input, Select, Checkbox, Switch
"use client";
import {
Checkbox,
Input,
Label,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
Switch,
Textarea,
} from "@waveinno/ui";
import * as React from "react";
export default function FormFields() {
const [on, setOn] = React.useState(true);
return (
<div className="grid max-w-xl gap-4 sm:grid-cols-2">
<div className="space-y-1.5">
<Label htmlFor="pg-name">Name</Label>
<Input id="pg-name" placeholder="Karim Ahmed" />
</div>
<div className="space-y-1.5">
<Label>City</Label>
<Select defaultValue="dhaka">
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="dhaka">Dhaka</SelectItem>
<SelectItem value="ctg">Chattogram</SelectItem>
<SelectItem value="sylhet">Sylhet</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-1.5 sm:col-span-2">
<Label htmlFor="pg-note">Note</Label>
<Textarea id="pg-note" placeholder="Anything the team should know" />
</div>
<label className="flex items-center gap-2 text-sm text-body">
<Checkbox defaultChecked /> Send a receipt
</label>
<label className="flex items-center gap-2 text-sm text-body">
<Switch checked={on} onCheckedChange={setOn} /> Notifications {on ? "on" : "off"}
</label>
</div>
);
}Import#
Everything comes from the package root. The example above uses:
import {
Checkbox,
Input,
Label,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
Switch,
Textarea,
} from "@waveinno/ui";Props#
Read from the source of this version, so they match the code exactly.
<Checkbox>
src/components/ui/checkbox.tsxAlso takes ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> (passed through).
<Input>
src/components/ui/input.tsx| Prop | Type | Default | Description |
|---|---|---|---|
state | "default" | "error" | "warning" | "success" | "default" | |
leading | React.ReactNode | — | Icon or text inside the box, before the value (a search icon, "৳", "+880"). |
trailing | React.ReactNode | — | After the value: a unit, a clear button, a status icon. |
Also takes InputHTMLAttributes<HTMLInputElement>.
<Label>
src/components/ui/label.tsx| Prop | Type | Default | Description |
|---|---|---|---|
required | boolean | — |
Also takes ComponentPropsWithoutRef<typeof LabelPrimitive.Root>.
<SelectContent>
src/components/ui/select.tsxAlso takes ComponentPropsWithoutRef<typeof SelectPrimitive.Content> (passed through).
<SelectItem>
src/components/ui/select.tsxAlso takes ComponentPropsWithoutRef<typeof SelectPrimitive.Item> (passed through).
<SelectTrigger>
src/components/ui/select.tsxAlso takes ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> (passed through).
<Switch>
src/components/ui/switch.tsxAlso takes ComponentPropsWithoutRef<typeof SwitchPrimitive.Root> (passed through).
<Textarea>
src/components/ui/input.tsx| Prop | Type | Default | Description |
|---|---|---|---|
state | "default" | "error" | "warning" | "success" | "default" |
Also takes TextareaHTMLAttributes<HTMLTextAreaElement>.
Install#
If the project does not have the package yet, add it, then follow the setup for Next.js or Vite once.
$ npm install @waveinno/ui