Playground

Password input

A password field with a show/hide toggle.

  • Built on native elements
  • The toggle is a button with aria-pressed named "Show password".
  • The field keeps autocomplete hints so password managers work.
  • Styles in one file: 03-form-fields.css

Import

import '@monoline/css';
import {PasswordInput} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add password-input

Usage

import {Field, PasswordInput} from '@monoline/react';

<div style={{maxWidth: '320px'}}>
  <Field label="Password">
    <PasswordInput autoComplete="current-password" />
  </Field>
</div>

Examples

Basic

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[aria-checked="true"]03-form-fields.css
[aria-invalid="true"]03-form-fields.css
[aria-pressed="true"]03-form-fields.css

CSS classes

ClassStylesheet
.field03-form-fields.css
.field-hint03-form-fields.css
.input03-form-fields.css
.input-bare03-form-fields.css
.input-end03-form-fields.css
.input-lg03-form-fields.css
.input-sm03-form-fields.css
.input-wrap03-form-fields.css
.muted03-form-fields.css
.seg03-form-fields.css
.seg-opt03-form-fields.css
.select03-form-fields.css
.setting03-form-fields.css
.switch03-form-fields.css
.textarea03-form-fields.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.field {
  border-color: var(--accent);
}
.field[aria-checked="true"] {
  background: var(--wash);
}

Accessibility

  • The toggle is a button with aria-pressed named "Show password".
  • The field keeps autocomplete hints so password managers work.