8.2.1 • Published 5 years ago

@lightspeed/cirrus-input v8.2.1

Weekly downloads
317
License
MIT
Repository
-
Last release
5 years ago

Input

The most generic form of them all is the input form. The input enables our users to fill in their data or content within our software. Each input can have an input Label, description, a required mark & a regular label. Input component includes a wide variety of options to quickly create accessible forms.


States

Input comes in more states than any other component, each for its own scenario. In this section, you’ll find a small description and scenario about each one.

StateDescription
NormalThis is the default state of each form.
EnteredWhen the user has given input on the form.
FocusedWhen the user has the form selected.
TypingThe user is currently typing inside the form.
DisabledForms with a disabled state can’t be used.
ErrorWhen the form has invalid content inside, note that each error state needs an error description as well.

Installation

First, make sure you have been through the Getting Started steps of adding Cirrus in your application.

If using Yarn:

yarn add @lightspeed/cirrus-input

Or using npm:

npm i -S @lightspeed/cirrus-input

Usage

Import required styles in your .scss:

@import '@lightspeed/cirrus-input/Input.scss';

React Component

Props

PropTypeDescription
idstringInputs ID, Recommended for accessibility
smallbooleanDisplay a small input
largebooleanDisplay a large input
labelstringInput's label above the input
labelHelperreact.nodeLabel helper aligned to the right
descriptionstringDescription above the input
prefixreact.nodeNode inside the input aligned to the left
suffixreact.nodeNode inside the input aligned to the right
textHelperstringHelp text below the input
disabledbooleanSet the input in a disabled state
statusobjectSets the status of the input { type: 'valid\|warning\|error', message: String\|Element }. The message will replace the textHelper
reffunctionA function that takes a DOM node as the argument and can return anything
html propertystringAny extra properties passed will be added to the <input> tag
classNamestringPassed to the <input /> tag

Example

import React from 'react';
import Input from '@lightspeed/cirrus-input';

const handleChange = (event) => {
    console.log(event.target.value);
}

const MyComponent = () =>
  <div>
    <Input
      id="username"
      name="username"
      placeholder="Username"
      data-attribute="custom attribute"
      onChange={handleChange}
    />
  </div>;

export default MyComponent;

CSS Component

Add classes to your HTML elements:

Component classes

Besides the base class .cr-input you can use one of these classes

TypeClass
small.cr-input--small
large.cr-input--large
valid.cr-input--valid
warning.cr-input--warning
error.cr-input--error

Component HTML

<div>
  <div class="cr-input__header">
    <div class="cr-input__label-wrapper">
      <label for="username" id="username-label" class="cr-text-base cr-text--body-small cr-text--bold">label</label>
      <div class="cr-input__label-helper">
        <span class="cr-label cr-label--info cr-label--small">label helper</span>
      </div>
    </div>
    <div id="username-description" class="cr-text-base cr-text--body-small">description text</div>
  </div>
  <div class="cr-input__wrapper">
    <div id="username-prefix" class="cr-input__prefix">prefix</div>
    <div id="username-suffix" class="cr-input__suffix">suffix</div>
    <input id="username" placeholder="Placeholder text..." aria-labelledby="username-label" aria-describedby="username-description" class="cr-input">
    <div class="cr-input__backdrop"></div>
  </div>
  <div class="cr-text-base cr-text--body-small cr-text--dimmed cr-input__text-helper">text helper</div>
</div>
8.2.1

5 years ago

9.0.0-beta.1

5 years ago

9.0.0-beta.0

5 years ago

9.0.0-alpha.1

5 years ago

9.0.0-alpha.0

5 years ago

8.2.0

5 years ago

8.1.0

6 years ago

8.0.2

6 years ago

8.0.1

6 years ago

8.0.0

6 years ago

7.0.1

6 years ago

7.0.0

6 years ago

6.0.0

6 years ago

5.0.4

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.0.0

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago