Skip to content
Open
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';
import { TextField } from '@toolpad/studio-components';

export default function TextFieldIsRequired() {
return <TextField label="Name" size="small" placeholder="Enter name" isRequired />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import { TextField } from '@toolpad/studio-components';

export default function TextFieldMaxlength() {
return (
<TextField
label="Zip code"
size="small"
maxLength="6"
placeholder="Enter zip code"
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';
import { TextField } from '@toolpad/studio-components';

export default function TextFieldMinlength() {
return (
<TextField
label="Password"
size="small"
minLength="6"
placeholder="Enter password"
password
isRequired
/>
);
}
14 changes: 11 additions & 3 deletions docs/data/toolpad/studio/components/text-field/text-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,25 @@ Disabled property shows the state of the component so that end user is aware tha

## Validation

The validation props offer the option to create an interactive text field component for various scenarios. These are available as a checkbox configurations in the Toolpad Studio editor.

### isRequired

isRequired is useful when the action can't be perfomed without a user provided text value.
isRequired prop is useful when the action can't be perfomed without a user provided text value. It can be used to assign mandatory fields.

{{"demo": "TextFieldIsRequired.js", "hideToolbar": true}}

### minLength

A validation check on the minimum length of the input.
A check on the minimum length of the input. In the below demo the input should be more than six characters long else it throws a validation error. It can be used to ensure passwords are long enough.

{{"demo": "TextFieldMinlength.js", "hideToolbar": true}}

### maxLength

A validation check on the maximum length of the input.
A validation check on the maximum length of the input. The below demo shows a validation error when the input breaches the limit of ten characters. In combination with other props, it can be used for zip codes, phone numbers, etc.

{{"demo": "TextFieldMaxlength.js", "hideToolbar": true}}

## API

Expand Down
26 changes: 13 additions & 13 deletions docs/data/toolpad/studio/reference/components/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ A text input with autocomplete suggestions. Uses the Material UI [Autocomplete]

## Properties

| Name | Type | Default | Description |
| :------------------------------------------ | :------------------------------------- | :------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <span class="prop-name">options</span> | <span class="prop-type">array</span> | <span class="prop-default">[]</span> | The options available to search from. |
| <span class="prop-name">value</span> | <span class="prop-type">string</span> | <span class="prop-default">""</span> | The value of the autocomplete. |
| <span class="prop-name">defaultValue</span> | <span class="prop-type">string</span> | <span class="prop-default">""</span> | A default value. |
| <span class="prop-name">label</span> | <span class="prop-type">string</span> | <span class="prop-default">"Search…"</span> | The label to display for the autocomplete. |
| <span class="prop-name">fullWidth</span> | <span class="prop-type">boolean</span> | | If true, the autocomplete will take up the full width of its container. |
| <span class="prop-name">size</span> | <span class="prop-type">string</span> | <span class="prop-default">"small"</span> | The size of the autocomplete. One of `small`, `medium`, or `large`. |
| <span class="prop-name">loading</span> | <span class="prop-type">boolean</span> | | If true, the autocomplete will display a loading indicator. |
| <span class="prop-name">disabled</span> | <span class="prop-type">boolean</span> | | If true, the autocomplete will be disabled. |
| <span class="prop-name">name</span> | <span class="prop-type">string</span> | | Name of this input. Used as a reference in form data. |
| <span class="prop-name">isRequired</span> | <span class="prop-type">boolean</span> | <span class="prop-default">false</span> | Whether the input is required to have a value. |
| <span class="prop-name">sx</span> | <span class="prop-type">object</span> | | The [`sx` prop](https://mui.com/toolpad/studio/concepts/theming/#overrides) is used for defining custom styles that have access to the theme. All MUI System properties are available via the `sx` prop. In addition, the `sx` prop allows you to specify any other CSS rules you may need. |
| Name | Type | Default | Description |
| :------------------------------------------ | :------------------------------------- | :------------------------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span class="prop-name">options</span> | <span class="prop-type">array</span> | <span class="prop-default">[]</span> | The options available to search from. |
| <span class="prop-name">value</span> | <span class="prop-type">string</span> | <span class="prop-default">""</span> | The value of the autocomplete. |
| <span class="prop-name">defaultValue</span> | <span class="prop-type">string</span> | <span class="prop-default">""</span> | A default value. |
| <span class="prop-name">label</span> | <span class="prop-type">string</span> | <span class="prop-default">"Search…"</span> | The label to display for the autocomplete. |
| <span class="prop-name">fullWidth</span> | <span class="prop-type">boolean</span> | | If true, the autocomplete will take up the full width of its container. |
| <span class="prop-name">size</span> | <span class="prop-type">string</span> | <span class="prop-default">"small"</span> | The size of the autocomplete. One of `small`, `medium`, or `large`. |
| <span class="prop-name">loading</span> | <span class="prop-type">boolean</span> | | If true, the autocomplete will display a loading indicator. |
| <span class="prop-name">disabled</span> | <span class="prop-type">boolean</span> | | If true, the autocomplete will be disabled. |
| <span class="prop-name">name</span> | <span class="prop-type">string</span> | | Name of this input. Used as a reference in form data. |
| <span class="prop-name">isRequired</span> | <span class="prop-type">boolean</span> | <span class="prop-default">false</span> | Whether the input is required to have a value. |
| <span class="prop-name">sx</span> | <span class="prop-type">object</span> | | The [`sx` prop](https://mui.com/system/getting-started/the-sx-prop/) is used for defining custom styles that have access to the theme. All MUI System properties are available via the `sx` prop. In addition, the `sx` prop allows you to specify any other CSS rules you may need. |
Loading