Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@element-public/react-textfield

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@element-public/react-textfield

Textfield component for Element React

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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

NameTypeDefaultRequiredDescription
classNamestringundefinedfalseThe css class name to be passed through to the component markup.
containerPropsobjectundefinedfalseProperties to be added to the container of the textfield.
counterbooleanfalsefalseEnables a character count. Warning requires maxlength to be set.
defaultValuestring | numberundefinedfalseThe starting value of the Textfield when working in uncontrolled mode.
densebooleanfalsefalseThe size of the Textfield will be reduced.
disabledbooleanfalsefalseTextfield will be disabled.
focusedbooleanfalsefalseSets the Textfield to the focused state.
fullWidthbooleanfalsefalseThe Textfield will expand to 100% width.
helperTextIdstringundefinedfalseRandomly generated id for the helper text container element. May be overwritten.
helperTextPersistentbooleanfalsefalseSet the helper text to be permanently visible.
helperTextValidationbooleanfalsefalseSet 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').
idstringundefinedfalseRandomly generated id for the input element. May be overwritten.
labelstringnullfalseFloating 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.
labelIdstringundefinedfalseRandomly generated id for the label element. May be overwritten.
leadingIconstring|React.ReactNodenullfalseAdds 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,
maxlengthnumbernullfalseRestricts the number of characters that can be entered, best used with counter.
noResizebooleantruefalsePrevents resizing when using textarea.
placeholderstringnullfalseNon-floating label text, will be replaced when the user starts typing.
prefixTextstringnullfalseText 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.
suffixTextstringnullfalseText 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.
textareabooleanfalsefalseEnabled multi-line text input. Note textarea cannot be used with the embedded variant.
tooltipboolean|objectnullfalseIf 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.
trailingIconstring|React.ReactNodenullfalseAdds 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.
typestring'text'falseSupport 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
validbooleantruefalseApplies an invalid style to the Textfield.
valuestring | numberundefinedfalseThe current value of the Textfield component.
variantstring'filled'falseApplies the selected styling to the Textfield. Note textarea does not support the embedded variant.
Accepted Values: filled, outlined, embedded

Textfield Deprecated Props

NameTypeDefaultRequiredDeprecatedDescription
blockbooleanundefinedfalseUse fullWidth instead.Applies a full-width style where the Textfield will fill its container.
containerClassstringundefinedfalseSee containerProps.Add a custom class to the Textfield container.
embeddedbooleanundefinedfalseUse `variant='embedded'An unfilled, non-outlined and full-width variant of Textfield, intended to be embedded in other components such as TopAppBar or TableHeader.
filledbooleanundefinedfalseUse variant='filled' instead.Apply filled style to the Textfield. Previously called primary.
maxLengthnumberundefinedfalseUse 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.
outlinedbooleanundefinedfalseUse variant='outlined' insteadApply outlined style to the Textfield. Previously called secondary.
primarybooleanundefinedfalseThis feature is no longer supported. Use variant='filled' instead.Enable filled styling.
searchbooleanundefinedfalseUse variant='embedded'Enabled search bar styling, including a full width style.
secondarybooleanundefinedfalseUse variant='outlined' instead.Apply secondary style to the Textfield.

Textfield Render Props

NameTypeDefaultRequiredDescription
helperTextReact.ReactNodenullfalseHelper text to be displayed below Textfield, by default only visible on focus.
leadingContentReact.ReactNodenullfalseCustom content to appear before the input.
trailingContentReact.ReactNodenullfalseCustom content to appear after the input.

Textfield Events

NameDefaultRequiredParamsDescription
onBlurnullfalseFired when focus leaves the input.
onChangenullfalseFired when each character is entered into the Textfield.
onFocusnullfalseFired 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'.

FAQs

Package last updated on 17 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc