react-html-components
v1.1.8
Published
Generic react html components for materializecss
Downloads
60
Maintainers
Readme
react-html-components
Generic html react components for materializecss
Getting started
Install npm package
npm install --save react-html-components
This package requires materializecss.
Usage
import {TextInput, Switch} from 'react-html-components';
Currently supported materialize elements:
- Form elements
- input type text (TextInput)
- input type email (EmailInput)
- input type password (PasswordInput)
- input type radio (RadioButton)
- input type checkbox (Checkbox)
- switch (Switch)
- Icons
- Icon
- TinyIcon
- SmallIcon
- MediumIcon
- LargeIcon
- Buttons
- Button
- LargeButton
- FlatButton
- FloatingButton
- Modal
Documentation
Form elements
Common attributes
value
- typestring
;checked
- typeboolean
;name
- typestring
;disabled
- typeboolean
;id
- typestring
;required
- typeboolean
;extraClass
- typestring
(is added toclass
attribute of<input/>
);label
- typestring
(injected withdangerouslySetInnerHTML
);changeCallback
- typefunction
(executed when input changes value/checked);mouseEnterCallback
- typefunction
(executed on hover of<input/>
);mouseLeaveCallback
- typefunction
(executed on mouse leave the<input/>
);
Methods
Following accessor methods are available through the React`s refs
:
value
- getter/setter;checked
- getter/setter;disabled
- getter/setter;required
- getter/setter;type
- getter;
Example:
someMethod(){
this.refs.textInput.value("new value"); // setter
this.refs.textInput.value() // getter
}
.......
render(){
return (
<TextInput ref="textInput" value="initial value" />
);
TextInput (type="text"
)
Supports common attributes.
Attributes
placeholder
- typestring
;
PasswordInput (type="password"
)
Supports common attributes.
Attributes
placeholder
- typestring
;
EmailInput (type="email"
)
Supports common attributes.
Attributes
placeholder
- typestring
;validate
- typebool
(reference materializecss documentation);errorMessage
- typestring
(data-error
attribute of<input/>
);successMessage
- typestring
(data-success
attribute of<input/>
);
Checkbox (type="checkbox"
)
Supports common attributes.
RadioButton (type="radio"
)
Supports common attributes.
Attributes
withGap
- typebool
(reference materializecss documentation);
Icons
Icon - base icon component
Attributes
classes
- typeArray
of css classes which will be concatenated with space;iconName
- typestring
- reference to materializecss docs;size
- typestring
(one of ["","tiny","small","medium","large"]);
TinyIcon (type={"tiny"})
SmallIcon (type={"small"})
MediumIcon (type={"medium"})
LargeIcon (type={"large"})
Example:
import { SmallIcon } from 'react-html-components';
.......
render(){
return (
<SmallIcon classes={["left"]} iconName={"cloud"} />
);
Buttons
Button
Button
- is a base component for buttons.
Methods (available through refs
)
disabled
- setter/getter;
Attributes
classes
- typeArray
of css classes which will be concatenated with space;clickCallback
- typefunc
- will be triggered on click (is not triggered on disabled buttons);disabled
- typebool
;type
- type oneOf(["", "btn-large", "btn-flat", "btn-floating"]) - should not be used normaly;
LargeButton (Button type={"btn-large"})
FlatButton (Button type={"btn-flat"})
FloatingButton (Button type={"btn-floating"})
Example:
import { LargeButton } from 'react-html-components';
.......
render(){
return (
<LargeButton disabled={true}>Test Button</LargeButton>
);
Modal
Attributes
type
- typestring
(default modal, if empty;bottom-sheet
,modal-fixed-footer
);
Methods (available through refs
)
open
- open modal;close
- close modal;
Example:
import { Modal, ModalContent, ModalFooter, FlatButton } from 'react-html-components';
render(){
return (
<Modal ref="modal" type="bottom-sheet">
<ModelContent>
Content
</ModalContent>
<ModalFooter>
<FlatButton classes={["modal-action modal-close waves-effect waves-green"]}>Agree</FlatButton>
</ModelFooter>
</Modal>
);
openModal(){
this.refs.modal.open();
}
closeModal(){
this.refs.modal.close();
}