14.2.2 • Published 4 days ago

@rmwc/textfield v14.2.2

Weekly downloads
7,446
License
MIT
Repository
github
Last release
4 days ago

Text Fields

Text fields allow users to input, edit, and select text.

  • Module @rmwc/textfield
  • Import styles:
    • Using CSS Loader
      • import '@rmwc/textfield/styles';
    • Or include stylesheets
      • '@material/textfield/dist/mdc.textfield.css'
      • '@material/floating-label/dist/mdc.floating-label.css'
      • '@material/notched-outline/dist/mdc.notched-outline.css'
      • '@material/line-ripple/dist/mdc.line-ripple.css'
      • '@material/ripple/dist/mdc.ripple.css'
      • '@rmwc/icon/icon.css'
  • MDC Docs: https://material.io/develop/web/components/input-controls/text-field/

TextField Variants

<TextField label="standard..." />
<TextField outlined label="outlined..." />
<TextField placeholder="No label" />
<>
  {/* Leading and trailing icons can be used.*/}
  <TextField icon="search" trailingIcon="close" label="icon..." />
  {/* If you need full control over the icon, you can pass the icon as options with your own props. Dont forget the TabIndex to make it clickable*/}
  <TextField
    label="trailingIcon..."
    trailingIcon={{
      icon: 'close',
      tabIndex: 0,
      onClick: () => console.log('Clear')
    }}
  />
</>
<TextField fullwidth label="fullwidth..." />

Textareas

You can make the TextField a textarea. Make sure to include outlined for proper styling You can optionally make help text always visible by passing an object as props with persistent set to true. Textareas can also have an optional character counter which will work with the maxLength property.

<div>
  <TextField
    textarea
    label="textarea..."
    rows={8}
    maxLength={20}
    characterCount
    resizeable
    helpText={{
      persistent: true,
      validationMsg: true,
      children: 'The field is required'
    }}
  />
</div>

Validation

<TextField disabled label="Disabled..." />
<TextField required label="Required..." value="" />
<TextField
  invalid
  label="Invalid..."
  value="#@!$"
  onChange={() => {}}
/>
<TextField label="Validate Pattern" pattern="[A-Za-z]{3}" />

HTML Input Types

A preview of how material-components-web handles styling input types for your browser.

<>
  <TextField label="text" type="text" />
  <TextField label="color" type="color" style={{ width: '6rem' }} />
  <TextField label="date" type="date" />
  <TextField label="datetime-local" type="datetime-local" />
  <TextField label="month" type="month" />
  <TextField label="range" type="range" />
  <TextField label="time" type="time" />
  <TextField label="week" type="week" />
</>

TextField

A TextField component for accepting text input from a user.

Props

NameTypeDescription
align"start" \| "end"How to align the text inside the TextField. Defaults to 'start'.
characterCountbooleanShows the character count, must be used in conjunction with maxLength.
disabledbooleanMakes the Textfield disabled.
floatLabelbooleanThe label floats automatically based on value, but you can use this prop for manual control.
foundationRefRef<null \| MDCTextFieldFoundation<>>Advanced: A reference to the MDCFoundation.
fullwidthbooleanMakes the TextField fullwidth.
helpTextReactNode \| TextFieldHelperTextPropsAdds help text to the field
iconIconPropTAdd a leading icon.
inputRefRef<null \| HTMLInputElement<> \| HTMLTextAreaElement<>>A reference to the native input or textarea.
invalidbooleanMakes the TextField visually invalid. This is sometimes automatically applied in cases where required or pattern is used.
labelReactNodeA label for the input.
outlinedbooleanOutline the TextField.
prefixstringAdd prefix.
requiredbooleanMakes the Textfield required.
resizeablebooleanMake textarea resizeable
rippleRipplePropTAdds a ripple effect to the component
rootPropsObjectBy default, props spread to the input. These props are for the component's root container.
suffixstringAdd suffix.
textareabooleanMakes a multiline TextField.
trailingIconIconPropTAdd a trailing icon.
typestringThe type of input field to render, search, number, etc
valuestring \| numberSets the value for controlled TextFields.
14.2.2

4 days ago

14.2.0

11 days ago

14.2.1

11 days ago

14.1.5

12 days ago

14.1.4

24 days ago

14.1.3

1 month ago

14.1.2

1 month ago

14.1.1

2 months ago

14.1.0

2 months ago

14.0.12

2 months ago

14.0.11

2 months ago

14.0.10

3 months ago

14.0.9

3 months ago

14.0.8

3 months ago

14.0.7

3 months ago

14.0.6

4 months ago

14.0.5

4 months ago

14.0.4

5 months ago

14.0.1-alpha.0

8 months ago

14.0.2-alpha.3

6 months ago

14.0.2-alpha.0

8 months ago

14.0.2-alpha.1

6 months ago

14.0.2-alpha.6

6 months ago

14.0.2-alpha.7

6 months ago

14.0.2-alpha.4

6 months ago

14.0.2-alpha.5

6 months ago

14.0.0

5 months ago

14.0.1

5 months ago

14.0.0-alpha.0

8 months ago

14.0.2

5 months ago

14.0.3

5 months ago

8.0.8

11 months ago

8.0.7

1 year ago

8.0.6

1 year ago

8.0.5

1 year ago

8.0.4

1 year ago

8.0.3

2 years ago

8.0.2

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

7.0.3

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

7.0.0

2 years ago

6.1.4

4 years ago

6.1.3

4 years ago

6.1.2

4 years ago

6.1.1

4 years ago

6.1.0

4 years ago

6.0.14

4 years ago

6.0.13

4 years ago

6.0.12

4 years ago

6.0.11

4 years ago

6.0.10

4 years ago

6.0.9

4 years ago

6.0.5

4 years ago

6.0.4

4 years ago

6.0.3

4 years ago

6.0.2

4 years ago

6.0.1

4 years ago

6.0.0

4 years ago

6.0.0-rc.4

4 years ago

6.0.0-rc.3

4 years ago

6.0.0-rc.2

4 years ago

6.0.0-rc.1

4 years ago

6.0.0-rc.0

4 years ago

6.0.0-alpha.16

4 years ago

6.0.0-alpha.14

4 years ago

6.0.0-alpha.15

4 years ago

6.0.0-alpha.13

4 years ago

6.0.0-alpha.12

4 years ago

6.0.0-alpha.11

4 years ago

6.0.0-alpha.7

4 years ago

5.7.2

4 years ago

6.0.0-alpha.6

4 years ago

6.0.0-alpha.5

4 years ago

6.0.0-alpha.3

4 years ago

5.7.0

5 years ago

5.6.0

5 years ago

5.5.2

5 years ago

5.5.1

5 years ago

5.5.0

5 years ago

5.4.3

5 years ago

5.4.2

5 years ago

5.4.1

5 years ago

5.4.0

5 years ago

5.3.1

5 years ago

5.3.0

5 years ago

5.2.2

5 years ago

5.2.1

5 years ago

5.2.0

5 years ago

5.2.0-alpha.0

5 years ago

5.1.8

5 years ago

5.1.7

5 years ago

5.1.6

5 years ago

5.1.5

5 years ago

5.1.4

5 years ago

5.1.3

5 years ago

5.1.2

5 years ago

5.1.1

5 years ago

5.1.0

5 years ago

5.0.30-rc.0

5 years ago

5.0.29-rc.0

5 years ago

5.0.28-rc.0

5 years ago

5.0.27-rc.0

5 years ago

5.0.26-rc.0

5 years ago

5.0.25-rc.0

5 years ago

5.0.24-rc.0

5 years ago

5.0.23-rc.0

5 years ago

5.0.23-alpha.0

5 years ago

5.0.22-alpha.0

5 years ago

5.0.21-alpha.0

5 years ago

5.0.20-alpha.0

5 years ago

5.0.19-alpha.0

5 years ago

5.0.18-alpha.0

5 years ago

5.0.17-alpha.0

5 years ago

5.0.16-alpha.0

5 years ago

5.0.15-alpha.0

5 years ago

5.0.14-alpha.0

5 years ago

5.0.13-alpha.0

5 years ago

5.0.12-alpha.0

5 years ago

5.0.11-alpha.0

5 years ago

5.0.8-alpha.0

5 years ago

5.0.7-alpha.0

5 years ago

5.0.6-alpha.0

5 years ago

5.0.5-alpha.0

5 years ago

5.0.4-alpha.0

5 years ago

5.0.3-alpha.0

5 years ago

5.0.2-alpha.0

5 years ago

5.0.1-alpha.0

5 years ago

5.0.0-alpha.0

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.0.11

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.8

5 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.0

6 years ago

2.2.2

6 years ago

2.2.0

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

2.0.0-alpha.7

6 years ago

2.0.0-alpha.6

6 years ago

2.0.0-alpha.5

6 years ago

2.0.0-alpha.4

6 years ago

2.0.0-alpha.3

6 years ago

2.0.0-alpha.2

6 years ago

2.0.0-alpha.1

6 years ago

2.0.0-alpha.0

6 years ago