انتقل إلى المحتوى الرئيسي

Form Components

Components for user input and actions.

Button

An action button with multiple variants, tones, and states.

import { Button } from "@qumra/manara";

// Variants
<Button variant="primary">Primary</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="tertiary">Tertiary</Button>
<Button variant="plain">Plain</Button>

// Tones
<Button variant="primary" tone="critical">Delete</Button>
<Button variant="primary" tone="success">Publish</Button>

// States
<Button loading>Saving...</Button>
<Button disabled>Disabled</Button>

// Full width
<Button variant="primary" fullWidth>Submit Order</Button>

// With icon
<Button icon={PlusIcon}>Add Product</Button>

// As link
<Button url="/products" external>View Products</Button>

// Submit button (for forms)
<Button variant="primary" submit>Submit</Button>

Props

PropTypeDefaultDescription
variant"primary" | "secondary" | "tertiary" | "plain""secondary"Visual style variant.
tone"default" | "critical" | "success""default"Color tone.
size"sm" | "md" | "lg""md"Button size.
fullWidthbooleanfalseStretch to full container width.
disabledbooleanfalseDisable the button.
loadingbooleanfalseShow loading spinner.
urlstring--Render as a link.
externalbooleanfalseOpen link in new tab.
iconReactNode--Icon element to display.
onClick() => void--Click handler.
submitbooleanfalseAct as a form submit button.
childrenReactNode--Button label.

TextField

A text input field with label, validation, and help text.

import { TextField } from "@qumra/manara";
import { useState } from "react";

function ProductForm() {
const [title, setTitle] = useState("");
const [price, setPrice] = useState("");

return (
<form>
<TextField
label="Product Title"
value={title}
onChange={setTitle}
placeholder="Enter product title"
helpText="The name customers will see."
/>

<TextField
label="Price"
type="number"
value={price}
onChange={setPrice}
prefix="SAR"
helpText="Set the selling price."
/>

<TextField
label="Description"
value=""
onChange={() => {}}
multiline={4}
placeholder="Describe your product..."
/>

<TextField
label="SKU"
value=""
onChange={() => {}}
error="SKU is required"
/>
</form>
);
}

Props

PropTypeDefaultDescription
labelstring--Input label text.
valuestring--Current input value.
onChange(value: string) => void--Change handler.
type"text" | "number" | "email" | "password" | "tel" | "url""text"Input type.
placeholderstring--Placeholder text.
helpTextstring--Help text below the input.
errorstring--Error message (shows red border).
prefixstring--Text prefix inside the input.
suffixstring--Text suffix inside the input.
multilinenumber--Number of rows for textarea mode.
disabledbooleanfalseDisable the input.
readOnlybooleanfalseMake the input read-only.
autoFocusbooleanfalseAuto-focus on mount.

Select

A dropdown select input for choosing from a list of options.

import { Select } from "@qumra/manara";
import { useState } from "react";

function StatusFilter() {
const [status, setStatus] = useState("active");

return (
<Select
label="Status"
value={status}
onChange={setStatus}
options={[
{ label: "Active", value: "active" },
{ label: "Draft", value: "draft" },
{ label: "Archived", value: "archived" },
]}
/>
);
}

Props

PropTypeDefaultDescription
labelstring--Select label text.
valuestring--Currently selected value.
onChange(value: string) => void--Change handler.
options{ label: string; value: string }[]--Available options.
placeholderstring--Placeholder when no value is selected.
helpTextstring--Help text below the select.
errorstring--Error message.
disabledbooleanfalseDisable the select.