> ## Documentation Index
> Fetch the complete documentation index at: https://docs.twenty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ввод

> Текстовое поле ввода с нативными атрибутами, интеграцией с полями и двумя размерами.

## Обзор

`Input` отображает текстовое поле ввода и принимает нативные атрибуты ввода, такие как `type`, `name`, `required`, `disabled` и `autoComplete`.

> [tab] Light
>
> [Пример Input (light)](https://storybook.twenty.com/iframe.html?id=ui-input-input--display\&viewMode=story\&globals=colorScheme:light)

> [tab] Dark
>
> [Пример Input (dark)](https://storybook.twenty.com/iframe.html?id=ui-input-input--display\&viewMode=story\&globals=colorScheme:dark)

[Open in Storybook](https://storybook.twenty.com/?path=/story/ui-input-input--display)

## Использование

### Неконтролируемое состояние

Используйте `defaultValue`, чтобы задать начальный адрес электронной почты. Поле ввода управляет последующими изменениями.

```tsx theme={null}
import { Field, Input } from 'twenty-ui/primitives/input';

export const EmailField = () => (
  <Field.Root>
    <Field.Label>Email</Field.Label>
    <Input
      name="email"
      type="email"
      autoComplete="email"
      defaultValue="alex@example.com"
    />
    <Field.Description>Use your work email address.</Field.Description>
  </Field.Root>
);
```

## Визуальные варианты

Сравните малые и средние поля ввода в состояниях по умолчанию, фокуса, ошибки и отключения. Используйте обратную связь при валидации вместе с оформлением ошибки.

> [tab] Light
>
> [Визуальные варианты поля ввода (light)](https://storybook.twenty.com/iframe.html?id=ui-input-input--catalog\&viewMode=story\&globals=colorScheme:light)

> [tab] Dark
>
> [Визуальные варианты поля ввода (dark)](https://storybook.twenty.com/iframe.html?id=ui-input-input--catalog\&viewMode=story\&globals=colorScheme:dark)

[Open in Storybook](https://storybook.twenty.com/?path=/story/ui-input-input--catalog)

## Простой внешний вид

Используйте `variant="plain"` внутри существующей строки или поверхности. Он убирает заливку, границу, скруглённые углы и внутренние отступы и использует естественную высоту. Родительский элемент задаёт отступы и размеры строки. Стили текста, заполнителя и отключённого состояния остаются общими. Синяя обводка соответствует нативному поведению браузера для `:focus-visible`. Для текстовых элементов управления это может включать фокус указателя и автофокусировку, а также фокус клавиатуры. Недопустимое состояние использует контур опасности без изменения макета.

```tsx theme={null}
import { Field, Input } from 'twenty-ui/primitives/input';

export const InlineSubject = () => (
  <Field.Root>
    <Field.Label>Subject</Field.Label>
    <Input variant="plain" placeholder="Add a subject" />
  </Field.Root>
);
```

`InputGroup` автоматически придает своему полю ввода простой вид и оставляет группу единственной рамкой фокуса и валидации. Его высоты `sm` и `md` остаются равными 24px и 32px. Отдельные простые поля ввода не используют фиксированную высоту, связанную с `size`.

## Контролируемое состояние

Передайте `value` и обновляйте его с помощью `onValueChange`, чтобы управлять тем же адресом электронной почты в состоянии React. Callback-функция получает следующее строковое значение и сведения о событии.

```tsx theme={null}
import { useState } from 'react';
import { Field, Input } from 'twenty-ui/primitives/input';

export const EmailField = () => {
  const [email, setEmail] = useState('alex@example.com');

  return (
    <Field.Root>
      <Field.Label>Email</Field.Label>
      <Input
        name="email"
        type="email"
        autoComplete="email"
        value={email}
        onValueChange={setEmail}
      />
      <Field.Description>Use your work email address.</Field.Description>
    </Field.Root>
  );
};
```

## Добавьте дополнение

`InputGroup` управляет окружающей рамкой и высотой макета. Размер ввода определяется явным дочерним `size`, затем значением группы по умолчанию, затем `md`. Сгруппированный ввод растягивается внутри общей рамки, поэтому для изменения общей высоты поля используйте `size` группы.

```tsx theme={null}
import { IconSearch } from 'twenty-ui/icon';
import { Input, InputGroup } from 'twenty-ui/primitives/input';

export const CompactSearch = () => (
  <InputGroup size="sm" startElement={<IconSearch size={16} aria-hidden />}>
    <Input aria-label="Search contacts" />
  </InputGroup>
);
```

## Настройка нативного элемента управления и обёртки

Нативные атрибуты, обработчики, `className`, `style` и `ref` относятся к вводу. Ref получает `HTMLInputElement`. Используйте `render`, чтобы скомпоновать другой компонент ввода и перенаправить предоставленные props и ref его нативному элементу ввода.

`onChange` получает событие изменения React для нативного элемента ввода. `onValueChange(value, details)` получает следующую строку и сведения о событии Base UI, включая `event`, `reason`, `cancel` и `allowPropagation`. Событие нацелено на элемент ввода. Отмена сведений сохраняет политику валидации Base UI; она не отменяет нативное редактирование. Управляемые вызывающие стороны определяют, какое значение фиксировать.

При настройке окружающей обёртки задавайте стили макета, атрибуты и ref для `InputGroup`. Группа не владеет значением. Нативные `name`, `form`, `required`, `readOnly`, `disabled`, а также поведение отправки и сброса остаются у элемента ввода, а именование и валидация Field предоставляются через `Field.Root`.

## Свойства

Справочник включает свойства, специфичные для компонента, и унаследованные свойства Base UI. Также поддерживаются нативные атрибуты ввода. Для автономного элемента ввода по умолчанию используется `md`; внутри группы размер элемента ввода `size`, если он не указан, наследует размер группы.

**className** `string | ((state: InputState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**defaultValue** `string | number | readonly string[]`

The default value of the input. Use when uncontrolled.

**hasFocusRing** `boolean` (default: true)

Set false to hide the focus border or outline while keeping errors visible. Defaults to true. InputGroup controls grouped focus styling.

**onValueChange** `((value: string, eventDetails: \{ reason: "none"; event: Event; cancel: () =\> void; allowPropagation: () =\> void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; \}) =\> void)`

Receives the next string value and Base UI details, including the native event, reason and cancellation methods.

**ref** `Ref\<HTMLInputElement\>`

Ref to the native input element.

**render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, InputState\>`

Composes the native input with a custom element or render callback. Forward the supplied props and ref to an input.

**size** `"md" | "sm"`

Visual size. Explicit input size takes precedence over the InputGroup default, then md applies. Group layout still sets the surrounding height.

**style** `CSSProperties | ((state: InputState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

**textAlign** `"end" | "start"`

Aligns text to the logical start or end of the input. Follows the text direction.

**value** `string | number | readonly string[]`

The value of the input. Use when controlled.

**variant** `"default" | "plain"` (default: default)

default keeps the field frame. plain removes fill, border, radius and padding and uses natural height. Its outline follows native :focus-visible, including pointer focus or autofocus on text inputs; invalid state uses a danger outline. InputGroup always owns the grouped frame.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.