@element-public/react-textfield
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Textfield

Description

Text fields let users enter and edit text into a UI.

See live demos on storybook

Storybook Textfield Demos

Install bundle from npm-e

npm i @element-public/react-components @element-public/themes

Optional: install the component individually

npm i @element-public/react-textfield @element-public/themes
Please Note: You will need to add @element-public to your .npmrc!

Open ~/.npmrc in an editor and add the following line to enable the @element-public scope:

@element-public:registry=https://npm.platforms.engineering

Troubleshooting

See below if you have never installed a package from Bayer's npm-enterprise or run into the following error:

npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR!     npm login

Setup an access token

See the devtools npm-e guide to learn how to create an access token if this is the first time you are using a npm-e package at Bayer or you do not have a line that starts with the following in your ~/.npmrc file:

//npm.platforms.engineering/:_authToken=

Notes

Textfield is an open text box that allows users to enter and/or edit text into a UI.

There are numerous Textfield props to enable customization of the component. Textfield has multiple different variants to choose from such as outlined, filled, and embedded - a special borderless textfield for inclusion in TopAppBar or TableTopBar.

Textfield Props

Name Type Default Required Description
className string undefined false The css class name to be passed through to the component markup.
containerProps object undefined false Properties to be added to the container of the textfield.
counter boolean false false Enables a character count. Warning requires maxlength to be set.
defaultValue string | number undefined false The starting value of the Textfield when working in uncontrolled mode.
dense boolean false false The size of the Textfield will be reduced.
disabled boolean false false Textfield will be disabled.
focused boolean false false Sets the Textfield to the focused state.
fullWidth boolean false false The Textfield will expand to 100% width.
helperTextId string undefined false Randomly generated id for the helper text container element. May be overwritten.
helperTextPersistent boolean false false Set the helper text to be permanently visible.
helperTextValidation boolean false false Set the helper text to use validation styles. Helper text changes with valid (e.g., helper text will appear red when valid is set to 'false').
id string undefined false Randomly generated id for the input element. May be overwritten.
label string null false Floating input label. Note: full-width Textfields do not support floating labels - any label on a full-width Textfield will be automatically mapped to a placeholder.
labelId string undefined false Randomly generated id for the label element. May be overwritten.
leadingIcon string|React.ReactNode null false Adds the given Icon or Icon Button to the left of the Textfield. Expects the name of a valid Material.io icon, however in React an icon or icon button component may be passed in instead for more control,
maxlength number null false Restricts the number of characters that can be entered, best used with counter.
noResize boolean true false Prevents resizing when using textarea.
placeholder string null false Non-floating label text, will be replaced when the user starts typing.
prefixText string null false Text that will appear before the label or value of the Textfield. It will be shown on focus. An example use-case might be a currency symbol such as $. Warning: This cannot be used with leadingIcon or textarea.
suffixText string null false Text that will appear after the label or value of the Textfield. It will be shown on focus. An example use-case might be .00 if handling currency. Warning: This cannot be used with trailingIcon or textarea.
textarea boolean false false Enabled multi-line text input. Note textarea cannot be used with the embedded variant.
tooltip boolean|object null false If defined, a Tooltip will appear on the Textfield. Useful to show the full value, if the value is too long for the Textfield width. The object should be the needed Tooltip properties. Tooltip text prop will be set to the current value of the Textfield. See Tooltip docs for available props.
trailingIcon string|React.ReactNode null false Adds the given Icon or Icon Button to the right of the Textfield . Expects the name of a valid Material.io icon, however in React an icon icon button component may be passed in instead for more control.
type string 'text' false Support for built-in input types. Browser support for some advanced types such as color or date may be limited or appear differently between browsers. Note the Datepicker component should be preferred over the built-in date/time types as it offers more consistency and features.Note Slider type is not support, please use the Element Slider component instead.
Accepted Values: text, password, color, email, url, number, tel, search, datetime-local, month, time, week, date
valid boolean true false Applies an invalid style to the Textfield.
value string | number undefined false The current value of the Textfield component.
variant string 'filled' false Applies the selected styling to the Textfield. Note textarea does not support the embedded variant.
Accepted Values: filled, outlined, embedded

Textfield Deprecated Props

Name Type Default Required Deprecated Description
block boolean undefined false Use fullWidth instead. Applies a full-width style where the Textfield will fill its container.
containerClass string undefined false See containerProps. Add a custom class to the Textfield container.
embedded boolean undefined false Use `variant='embedded' An unfilled, non-outlined and full-width variant of Textfield, intended to be embedded in other components such as TopAppBar or TableHeader.
filled boolean undefined false Use variant='filled' instead. Apply filled style to the Textfield. Previously called primary.
maxLength number undefined false Use maxlength instead. The case of this prop has changed to be more consistent. Restricts the number of characters that can be entered, best used with counter.
outlined boolean undefined false Use variant='outlined' instead Apply outlined style to the Textfield. Previously called secondary.
primary boolean undefined false This feature is no longer supported. Use variant='filled' instead. Enable filled styling.
search boolean undefined false Use variant='embedded' Enabled search bar styling, including a full width style.
secondary boolean undefined false Use variant='outlined' instead. Apply secondary style to the Textfield.

Textfield Render Props

Name Type Default Required Description
helperText React.ReactNode null false Helper text to be displayed below Textfield, by default only visible on focus.
leadingContent React.ReactNode null false Custom content to appear before the input.
trailingContent React.ReactNode null false Custom content to appear after the input.

Textfield Events

Name Default Required Params Description
onBlur null false Fired when focus leaves the input.
onChange null false Fired when each character is entered into the Textfield.
onFocus null false Fired when the input gains focus.

Textfield Breaking Changes

Description
children (removed): Please use value prop instead.
containerStyle (removed): See containerProps.
defaultContent (removed): This feature never quite worked correctly and is no longer supported.
errorChecking (removed): Use valid instead.
fullWidth: The behavior of fullWidth has changed since the previous version. If you need that original behavior use variant='embedded'.

Readme

Keywords

none

Package Sidebar

Install

npm i @element-public/react-textfield

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

194 kB

Total Files

7

Last publish

Collaborators

  • peon125
  • slowikowskiarkadiusz
  • arkadiusz.slowikowski