Input
Input abstracts away the cross-platform differences of placeholder styling and behaviors, for example: Internet Explorer dismisses native placeholders on input focus and other platforms do not. This component ensures that text input controls will feel and behave similarly on more devices.
Component Instance Methods
When using Input
in your project, you may call the following methods on a rendered instance of the component. Use refs
to get the instance.
-
getValue() returns the current value of the input field
-
setValue(string) programmatically set the input value; useful for clearing out the input in "uncontrolled" mode -- note that digging into the internals and setting the
refs.field.value = ''
directly will not trigger events and messes up the internal state of the component
Installation
npm i boundless-input --save
Then use it like:
/** @jsx createElement */ import createElement PureComponent from 'react';import Input from 'boundless-input'; state = input: '' this { return <div ='spread'> <div> <h5>hidePlaceholderOnFocus="false"</h5> <Input = = /> </div> <div => <h5>hidePlaceholderOnFocus="true"</h5> <Input = = /> </div> <div => <h5>"controlled" input</h5> <Input = = /> </div> </div> ; }
Input can also just be directly used from the main Boundless library. This is recommended when you're getting started to avoid maintaining the package versions of several components:
npm i boundless --save
the ES6 import
statement then becomes like:
;
Props
Note: only top-level props are in the README, for the full list check out the website.
Required Props
There are no required props.
Optional Props
-
*
· any React-supported attributeExpects Default Value any
n/a
-
component
· overrides the HTML container tagExpects Default Value string
'div'
-
hidePlaceholderOnFocus
· triggers the placeholder to disappear when the input field is focused, reappears when the user has tabbed away or focus is movedExpects Default Value bool
true
-
inputProps
Expects Default Value object
{ type: 'text' }
Reference Styles
Stylus
You can see what variables are available to override in variables.styl.
// Redefine any variables as desired, e.g:color-accent = royalblue // Bring in the component styles; they will be autoconfigured based on the above@require "node_modules/boundless-input/style"
CSS
If desired, a precompiled plain CSS stylesheet is available for customization at /build/style.css
, based on Boundless's default variables.