Theme
Design your own
On this page (3)
Component Skill — components/password-reset/component-skill.md

Native basis

A card: the new password (autocomplete="new-password", minlength, rules in aria-describedby) and its confirmation, then submit. data-variant="done" confirms and links back to sign in.

Built from

Input, Label, Button.

Web Platform APIs

autocompleteConstraint validation:user-invalid

Classes

.mk-password-reset.mk-password-reset-head.mk-auth-field.mk-password-reset-row.mk-password-reset-foot.mk-password-reset-rules.mk-password-reset-icon

Data attributes

data-variant="done".

§Default

Both fields use autocomplete="new-password" so the browser can generate and fill one strong password; minlength checks it and the rules are its description.

§Done

data-variant='done': the password changed - other sessions were signed out - and the way to sign in.

§CSS view file

/* -- Password Reset (website · Account & States) --------------------------
   Collects and confirms a replacement password - the new password with its rules, the confirmation, and the done state. */
@layer components {
  /* every box in the block measures border-box - the same on any page */
  :where(.mk-password-reset, .mk-password-reset *, .mk-password-reset ::before, .mk-password-reset ::after) {
    box-sizing: border-box;
  }
  .mk-password-reset {
    container: mk-password-reset / inline-size;
    display: grid;
    gap: 1.5rem;
    width: 100%;
    max-width: 24rem;
    margin-inline: auto;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--card);
    color: var(--card-foreground);
    box-shadow: var(--shadow-sm);
  }
  .mk-password-reset-head {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    text-align: center;
    & > svg {
      width: 2rem;
      height: 2rem;
      color: var(--primary);
    }
    & h1,
    & h2 {
      margin: 0.25rem 0 0;
      font-size: 1.5rem;
      font-weight: 700;
      letter-spacing: -0.02em;
    }
    & p {
      margin: 0;
      color: var(--muted-foreground);
      font-size: 0.9375rem;
      text-wrap: pretty;
    }
  }
  .mk-password-reset form {
    display: grid;
    gap: 1rem;
  }
  .mk-password-reset .mk-auth-field {
    display: grid;
    gap: 0.375rem;
  }
  .mk-password-reset-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.875rem;
    & a {
      color: var(--primary);
      font-weight: 500;
      text-decoration: none;
    }
    & a:hover {
      text-decoration: underline;
      text-underline-offset: 3px;
    }
  }
  .mk-password-reset-foot {
    margin: 0;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    text-align: center;
    & a {
      color: var(--primary);
      font-weight: 600;
      text-decoration: none;
    }
    & a:hover {
      text-decoration: underline;
      text-underline-offset: 3px;
    }
  }
  .mk-password-reset .btn {
    width: 100%;
  }
  .mk-password-reset .input:user-valid {
    border-color: #16a34a;
  }
  .mk-password-reset-rules {
    margin: 0.25rem 0 0;
    padding-inline-start: 1.125rem;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    line-height: 1.6;
  }
  .mk-password-reset-icon {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--muted);
    & svg {
      width: 1.375rem;
      height: 1.375rem;
    }
  }
  .mk-password-reset[data-variant="done"] .mk-password-reset-icon {
    background: color-mix(in oklch, #16a34a 14%, transparent);
    color: #15803d;
  }
  /* -- Accessibility ------------------------------------------- */
  @media (forced-colors: active) {
    .mk-password-reset {
      border-color: CanvasText;
    }
  }
}

Comments, ideas or improvements? Edit this page's source on GitHub