Socket
Socket
Sign inDemoInstall

@material/react-text-field

Package Overview
Dependencies
20
Maintainers
12
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @material/react-text-field

Material Components React Text Field


Version published
Weekly downloads
6.5K
increased by24.37%
Maintainers
12
Created
Weekly downloads
 

Changelog

Source

0.2.0 (2018-06-01)

Bug Fixes

  • Remove scss extensions from @material/mdc-* imports (#62) (46b7f08)
  • button: Rename stroked to outlined (#74) (f612388)
  • infrastructure: fixed npm run build error for empty package directories (#85) (18666d4)
  • infrastructure: Make all components public (#43) (27a1ab1)
  • ripple: Trigger on key events (2248f26)

Features

<a name="0.1.0"></a>

Readme

Source

React Text Field

MDC React Text Field is component for MDC Text Field. Please see MDC Text Field.

Installation

npm install @material/react-text-field

Usage

React Text Field accepts one child element which is the input element. For ease of integration, we have provided an input component to be used with React Text Field.

import React from 'react';
import TextField, {HelperText, Input} from '@material/react-text-field';

class MyApp extends React.Component {
  state = {value: 'Woof'};

  render() {
    return (
      <div>
        <TextField
          label='Dog'
          HelperText={<HelperText>Help Me!</HelperText>}
        >
          <Input
            value={this.state.value}
            onChange={(e) => this.setState({value: e.target.value})}/>
        </TextField>
      </div>
    );
  }
}

NOTE: In order to get access to the value, you must add an onChange handler, which accepts an event and updates the value of the input as shown above.

Props

Prop NameTypeDescription
boxBooleanEnables box variant.
childrenElementMandatory. The input element of the text field.
classNameStringAn optional class added to the .mdc-text-field element.
denseBooleanEnables dense variant.
floatingLabelClassNameStringAn optional class added to the floating label element fo the text field.
fullWidthBooleanEnables fullWidth variant.
helperTextElementHelper text that appears below the text field. Use the <HelperText> component that comes with this package.
labelStringMandatory. Label text that appears as the floating label or placeholder.
leadingIconElementAn icon element that appears as the leading icon.
lineRippleClassNameStringAn optional class added to the line ripple element.
notchedOutlineClassNameStringAn optional class added to the notched outline element.
outlinedBooleanEnables outlined variant.
textareaBooleanEnables textarea variant.
trailingIconElementAn icon element that appears as the trailing icon.

Input Props

Not all the props below are used for majority of cases. Properties like foundation shouldn't be used when implementing the text field, but is used internally in React Text Field.

Prop NameTypeDescription
classNameStringClasses to be applied to the input element.
disabledFunctionDisables the input and the parent text field.
foundationFunctionThe text field foundation.
handleValueChangeFunctionA callback function to update React Text Field's value.
idStringThe <input> id attribute.
onBlurFunctionBlur event handler.
onChangeFunctionChange event handler.
onFocusFunctionFocus event handler.
onMouseDownFunctionMouse down event handler.
onTouchStartFunctionTouch start event handler.
setDisabledFunctionCallback function that is called when the disabled prop updates.
setInputIdFunctionCallback function that is called when the id attribute updates.
handleFocusChangeFunctionCallback function that is called when focus or blur events occur
valueNumber/StringValue of the input.

NOTE: the <Input> component will receive all properties that a standard <input> accepts.

Styles

To style Notched Outline, Floating Label, and Line Ripple correctly, please include the Sass imports along with the Text Field sass imports. For reference your Sass file should include imports like so:

@import "@material/react-floating-label/index.scss";
@import "@material/react-line-ripple/index.scss";
@import "@material/react-notched-outline/index.scss";

@import "@material/react-text-field/index.scss";

Sass Mixins

Sass mixins may be available to customize various aspects of the Components. Please refer to the MDC Web repository for more information on what mixins are available, and how to use them.

Advanced Sass Mixins

Keywords

FAQs

Last updated on 01 Jun 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc