Nº 335 of 520
Password field
A password that starts hidden. Show reveals gate-1842. Hide puts it back. The hint says the yard issued it.
Preview
Use it
Free to use · credit appreciated1 Once, in your project
npx skills add SusanAcharya/Design-Lounge 2 Then ask
Using the Design Lounge skill, build "Password field" (piece password-field) in my stack. Match its brief; restyle it onto my product's theme.
No skill? Paste the brief instead. It carries the numbers, tokens and behaviour.
<!-- Design Lounge Nº 335 · "Password field" · designlounge.vercel.app -->
# Password field
> **Build brief for a coding agent.** Rebuild this piece in the reader's stack. If they haven't said which stack, ask once, then default to semantic HTML + CSS + a little vanilla JS. Match the numbers below; don't "improve" them. When a kit is locked, the field and Show share `--control` and `--radius`. This is `text-field` plus the reveal. Do not invent a second input style.
## What it is
The password on the yard account. It starts as `type="password"` with the value gate-1842, so the glyphs are masked. Show sits to the right of the field, same 40px height, outline. Pressing Show sets the type to text, the button to Hide, and `aria-pressed` to true. Pressing Hide masks it again. The hint under the field says the yard issued it and it is not the badge number. There is no strength meter and no second rule about symbols.
## Reference behaviour
1. The field is masked. Show is not pressed. The hint is visible.
2. Show reveals gate-1842 and the button reads Hide.
3. Hide masks it again and the button reads Show.
4. The value does not change when you toggle. Only the type changes.
5. There is no animation and no submit.
6. Focus ring is 2px `--focus`, offset 2px, on the field and on the button.
## Structure
```
padding 48px 64px
Yard account 12px
width 320
Password label
[ masked ] [ Show ] both 40px
The yard issued this. It is not the badge number.
```
- The label is tied to the input.
- Show has `aria-controls` pointing at the input and `aria-pressed`.
- The hint is a paragraph under the row.
## Tokens
```css
:root {
--bg: #f6f4ef;
--surface: #ffffff;
… 123 more lines. Copy or download for the full brief. Loading the source…Brief
163 linesBuild brief for a coding agent. Rebuild this piece in the reader’s stack. If they haven’t said which stack, ask once, then default to semantic HTML + CSS + a little vanilla JS. Match the numbers below; don’t “improve” them. When a kit is locked, the field and Show share
--controland--radius. This istext-fieldplus the reveal. Do not invent a second input style.
What it is
The password on the yard account. It starts as type="password" with the value gate-1842, so the glyphs are masked. Show sits to the right of the field, same 40px height, outline. Pressing Show sets the type to text, the button to Hide, and aria-pressed to true. Pressing Hide masks it again. The hint under the field says the yard issued it and it is not the badge number. There is no strength meter and no second rule about symbols.
Reference behaviour
- The field is masked. Show is not pressed. The hint is visible.
- Show reveals gate-1842 and the button reads Hide.
- Hide masks it again and the button reads Show.
- The value does not change when you toggle. Only the type changes.
- There is no animation and no submit.
- Focus ring is 2px
--focus, offset 2px, on the field and on the button.
Structure
padding 48px 64px
Yard account 12px
width 320
Password label
[ masked ] [ Show ] both 40px
The yard issued this. It is not the badge number.
- The label is tied to the input.
- Show has
aria-controlspointing at the input andaria-pressed. - The hint is a paragraph under the row.
Tokens
:root {
--bg: #f6f4ef;
--surface: #ffffff;
--ink: #161513;
--ink-2: #5a554c;
--ink-3: #5c564e;
--line-strong: #cfc6b8;
--focus: #1f4d3a;
--sans: "IBM Plex Sans", system-ui, sans-serif;
}
Radius is 2px. The family replaces it on both controls. Show is outline. It is not a second primary. The screen’s primary, if this sits on a sign-in, is the submit, which is not in this piece.
Typography
| Role | Family | Size | Weight | Colour |
|---|---|---|---|---|
| Where | sans | 12px | 500 | --ink-2 |
| Label | sans | 12px | 500 | --ink-2 |
| Value | sans | 14px | 400 | --ink |
| Show | sans | 13px | 500 | --ink |
| Hint | sans | 12px | 400 | --ink-3 |
The where-line letter-spacing is 0.04em. The masked value uses the browser’s password glyphs. Do not draw dots in a second font.
Motion
None. The type swaps in one frame. Reduced motion has nothing to remove.
| Thing | Trigger | What changes |
|---|---|---|
| Show | click | type text, label Hide, pressed |
| Hide | click | type password, label Show, not pressed |
States
- Field: height 40px, padding 0 12px, radius 2px, 1px
--line-strong, surface, flex 1. - Show resting: height 40px, padding 0 14px, outline,
aria-pressed="false". - Show pressed: the same outline. The word changes to Hide. Do not fill it solid.
- Hint: 12px
--ink-3. - Focus-visible: 2px outline, offset 2px.
- Do not add an eye icon from outside Lounge Icons. This demo uses the word, which is the accessible name.
Accessibility
- The label Password is visible.
- Show and Hide are the button names.
aria-pressedmatches the revealed state. - The hint is in the field group, so it is read with the control.
- Autocomplete is
current-password. - Hit targets are 40px. On a phone, at least 44px.
- Contrast of the value and the hint on the paper clears 4.5.
- Revealing the password is a choice. Do not reveal it on focus alone.
Responsive rules
- At 1280 the group is 320px, padding 48px 64px.
- Below 640 the group is full width inside 20px padding. Show stays on the right of the field. If the row is under 280px, Show may wrap under and stay 40px tall.
- Do not replace this with a native reveal that ignores the radius.
Acceptance checklist
- The label is Password. The value is gate-1842. It starts masked.
- Show reveals the value and reads Hide.
- Hide masks it and reads Show.
- The hint says the yard issued it and it is not the badge number.
- Field and button are 40px tall, radius 2px.
- Show is outline, not a solid primary.
-
aria-pressedis true only while the value is visible. - Focus ring is 2px, offset 2px.
- There is no strength meter and no animation.
- The value is unchanged by the toggle.
Implementation notes
Toggle the type. Do not copy the value into a second element.
const on = pw.type === 'password';
pw.type = on ? 'text' : 'password';
show.textContent = on ? 'Hide' : 'Show';
Common mistakes:
- A text field with no reveal, so the person cannot check what they typed.
- An eye icon with no name.
- Show as a solid primary beside a sign-in button that is also solid.
- A strength meter with four colours. This piece does not score the password.
- Clearing the value when it is revealed.
- A different radius on Show than on the field.
Where it sits in a product:
- It is the password control.
text-fieldis the open text.otp-codeis a code from a letter. - Show is outline. One primary per view, and it is not Show.
- Height and radius come from the family.
- The hint stays
--ink-3. An error, if the password is wrong, replaces the hint in--danger, the same rule astext-field. This demo does not fail. - When a theme is locked, the paper and the ink come from the theme.
- Do not log the value. Do not put it in the hint.
- The where-line Yard account matches the text field. The badge number there is Y-1842. This password is gate-1842. They are different.
- A sign-in page is
split-sign-in. Use this control on it. Do not draw a third password style. - Keep the credit line on the token block.
- One password field. A confirm field is a second one of the same control, with its own label.
Rebuild order:
- Set the paper and IBM Plex Sans.
- Place the label, the masked field, and Show.
- Place the hint.
- Wire the toggle.
- Check the value survives Hide.
- Map height and radius onto the family.
Copy you keep:
- Yard account.
- Password.
- gate-1842.
- Show. Hide.
- The yard issued this. It is not the badge number.
Details
- Palette
- Type
- IBM Plex Sans
- Motion
- Static
- Build
- Quick build
- Tags
On the shelves