0.12.1 • Published 3 years ago

@bdt-component-library/text-field v0.12.1

Weekly downloads
47
License
MIT
Repository
github
Last release
3 years ago

TextField Component

About

This is a component published as its own package from our component library monorepo: https://github.com/BenefitsDataTrust/ui-components. Setup instructions, as well as higher-level goals and concerns can be found from the main project README.

Description

Handles display of text fields according to style guide.

API

proptyperequireddefaultexplanation
classNamestringno""Adds an optional classname to the text field
idstringyesnoInput id attr
valuestringnonoInput value
defaultValuestringnonoInput default value
requiredbooleannofalseDetermines if the input is required
namestringnonoInput name attr
inputRefanynonoReact ref for input
placeholderstringnonoInput placeholder text
autoCompleteenum("on", "off")noundefinedInput autoComplete attr
autoFocusbooleannofalseInput autoFocus attr
disabledbooleannoundefinedDetermines input disabled state
helperTextstringnonoInput helper text
onChangefunctionnoundefinedEvent handler for onchange events
onSearchCancelfunction(e: event)no() => {}Event handler for the cancel search click
typeenum("text", "date", "email", "password", "number", "search")no"text"Determines text field type
hasSuccessbooleannoundefinedDetermines success state
hasErrorbooleannoundefinedDetermines error state (if the error array is not empty)
leadingIconReact element OR falsenofalseShows the icon in the leading position
trailingIconReact element OR falsenofalseShows the icon in the trailing position
sizenumberno50Determines the value for the size attr
fullWidthbooleannofalseSets full width, overriding size attr
minnumbernoundefinedSets min attr for numerical inputs
maxnumbernoundefinedSets max attr for numerical inputs
noBottomMarginbooleannofalseRemoves bottom margin of input for more control over formatting
stepnumberno1Sets step attr for numerical inputs
testIdstringno""Allows an id to be added for testing purposes via the data-testid attr
minLengthnumbernoundefinedSets minLength attr for text inputs. Warning: this makes use of the native minLength input attr which depends on the utilization of the :invalid pseudo-class. Consider using onBlur for more complex validations with state.
maxLengthnumbernoundefinedSets maxLength attr for text inputs. Warning: this makes use of the native maxLength input attr. Consider using onBlur for more complex validations with state
onBlurfunction(e: event)no() => {}Event handler for onblur events
readOnlybooleannofalseProperty that prevents the user from entering text in the input
0.12.1

3 years ago

0.11.0

4 years ago

0.12.0

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.3

4 years ago

0.9.1

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.3

4 years ago

0.2.4

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago