nili/ui
همه‌ی کامپوننت‌ها

TextInput

نمای کلی
۲۷ اکسپورت۸ محور واریانت۱۳۴ پراپ۹ فایل
import { CounterInput, DigitInput, InlineInput, InputSelect, TagInput, TextInput } from '@nili/ui';

این همان صفحه‌ی نمای کلیِ خود کتابخانه است که زنده رندر می‌شود. زبان یا تم را از هدر عوض کنید، همراهش می‌آید.

انواع

دوازده پیش‌تنظیم از صفحهٔ فیگما. هرکدام کیبورد، تکمیل خودکار و جهت را متناسب با نوع مقداری که خواسته می‌شود تنظیم می‌کند. آرایه‌ها اسلات‌اند — startIcon، endIcon، startAffix، endAffix، select، button، emojiPicker.

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

https://

این یک متن راهنماست برای کمک به کاربر.

$

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

این یک متن راهنماست برای کمک به کاربر.

import {
  TextInput,
  InputSelect,
  Icon,
  Button,
  CompactButton,
} from "@nili/ui"
import { RiMailLine, RiSearchLine, RiBankCardLine } from "@remixicon/react"

export function Example() {
  return (
    <>
      <TextInput
        type="email"
        label="Email Address"
        sublabel="(Optional)"
        information
        hint="This is a hint text to help user."
        placeholder="hello@nili.design"
        startIcon={<Icon icon={RiMailLine} />}
        required
      />

      <TextInput
        type="phone"
        label="Phone Number"
        select={
          <InputSelect icon={<span>🇺🇸</span>} aria-label="Country code">
            +1
          </InputSelect>
        }
      />

      <TextInput type="website" label="Website" startAffix="https://" />

      <TextInput
        type="amount"
        label="Amount"
        prefix="$"
        select={
          <InputSelect icon={<span>🇪🇺</span>} aria-label="Currency">
            EUR
          </InputSelect>
        }
      />
    </>
  )
}

حالت‌ها و اندازه‌ها

پیش‌فرض، پرشده، غیرفعال و خطا در هر سه اندازه. هاور و فوکوس حالت‌های CSS‌اند، پس اینجا کشیده نشده‌اند.

ماتریس اندازه · ایمیل · جست‌وجو · مبلغ
$
$
$
import { TextInput } from "@nili/ui"

export function Example() {
  return (
    <>
      <TextInput label="Default" placeholder="Enter text..." />
      <TextInput label="Filled" defaultValue="hello@nili.design" type="email" />
      <TextInput label="Disabled" defaultValue="Locked" disabled />
      <TextInput
        label="Error"
        defaultValue="not-an-email"
        type="email"
        error="Enter a valid email address"
      />
      <TextInput size="sm" label="Small" />
      <TextInput size="xs" label="X-Small" />
    </>
  )
}

ورودی برچسب

فیلدی ویژه برای ساختن و مدیریت برچسب‌ها. Enter یا ویرگول ثبت می‌کند؛ Backspace روی فیلد خالی آخری را برمی‌دارد.

  • Berlin
  • London
  • Paris

برای افزودن برچسب Enter را بزنید

  • Tehran
import { TagInput } from "@nili/ui"

export function Example() {
  return (
    <TagInput
      label="Cities"
      hint="Press Enter to add a tag"
      defaultValue={["Berlin", "London", "Paris"]}
      placeholder="Add a city..."
      dismissLabel="Remove"
    />
  )
}

ورودی شمارنده

یک فیلد عددی با دکمه‌های افزایش و کاهش چسبیده به آن.

2

بین ۱ تا ۱۰

2

بین ۱ تا ۱۰

2

بین ۱ تا ۱۰

import { CounterInput } from "@nili/ui"

export function Example() {
  return (
    <CounterInput
      label="Guests"
      hint="Between 1 and 10"
      defaultValue={2}
      min={1}
      max={10}
      decrementLabel="Decrease"
      incrementLabel="Increase"
    />
  )
}

ورودی رقمی

داده‌های عددی را رقم‌به‌رقم می‌گیرد — کدهای یک‌بارمصرف و پین. پیست کل مجموعه را پر می‌کند.

کدی به تلفن شما فرستادیم

import { DigitInput } from "@nili/ui"

export function Example() {
  return (
    <>
      <DigitInput
        length={4}
        label="Verification code"
        hint="We sent a code to your phone"
        groupLabel="Verification code"
        cellLabel={(index, total) => `Digit ${index} of ${total}`}
      />
      <DigitInput
        length={6}
        error={t('f.codeWrong')}
        defaultValue="123"
        groupLabel="PIN"
        cellLabel={(index, total) => `Digit ${index} of ${total}`}
      />
    </>
  )
}

ورودی درون‌خطی

فیلدی فشرده برای ویرایش داده در جای خودش. حاشیه فقط روی هاور و فوکوس ظاهر می‌شود — تا دست نزنید مثل متن خوانده می‌شود.

import { InlineInput, Icon, CompactButton } from "@nili/ui"
import { RiUser3Line, RiPencilLine } from "@remixicon/react"

export function Example() {
  return (
    <InlineInput
      label="Display name"
      placeholder="Enter a name"
      defaultValue="Ada Lovelace"
      startIcon={<Icon icon={RiUser3Line} />}
      button={
        <CompactButton appearance="ghost" size="md" aria-label="Edit">
          <Icon icon={RiPencilLine} />
        </CompactButton>
      }
    />
  )
}