Skip to main content

TextInput

Collects a string, optionally framed by prefix and postfix adornments.

It is the fallback for every string field without a more specific format, and also backs the email, url and password formats through the type prop.

Example​

<TextInput source="sku" prefix="#" />
<TextInput source="description" multiline />
<TextInput source="contact_email" type="email" />

Props​

On top of these the component accepts the shared input props and React Admin's TextInput props.

NameTypeDefaultDescription
source (required)string—Name of the field in the form record
multilinebooleanfalseRenders a growing textarea instead of a single line
typestring'text'HTML input type — 'email', 'url', 'password' are set by the dispatcher
disabledbooleanfalseDisables the input
readOnlybooleanfalseRenders the value without allowing edits
prefixstring—Adornment before the value
postfixstring—Adornment after the value

Schema mapping​

Any string field without a recognised format; format: "text" turns multiline on, and email / url / password set the HTML input type.

{"name": "description", "type": "string", "format": "text", "helpText": "Shown on the product page"}
from habarico.serializers import AdminModelSerializer, TextField


class ProductSerializer(AdminModelSerializer):
description = TextField(required=False)

class Meta:
model = Product
fields = ["id", "name", "description"]

See also​