Skip to content

Commit

Permalink
Add to README
Browse files Browse the repository at this point in the history
  • Loading branch information
stephl3 committed Apr 25, 2024
1 parent 16e2dca commit 2cf7805
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/password-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ import { PasswordInput } from '@leafygreen-ui/password-input';
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `id` | `string` | id associated with the password input. | |
| `label` | `string` | Text shown above the password input. | |
| `aria` | `string` | Text shown above the password input. | |
| `value` | `string` | The controlled value of the password input. | |
| `disabled` | `boolean` | Disables the password input but still allows you to toggle password visibility. | `false` |
| `onChange` | `function` | The event handler function for the 'onchange' event. Accepts the change event object as its argument and returns nothing. |
Expand All @@ -125,9 +124,14 @@ const State = {
Valid: 'valid', // green checkmark, black text
None: 'none', // gray checkmark, gray text
} as const;

```

### Validation Feedback
Password input has 3 different supported options for validation feedback:
1. Pass the id of a custom notification as the `aria-describedby` prop and pass a `state` value string as the `stateNotifications` prop to link a custom notification to the password input.
2. Pass an array of notifications as the `stateNotifications` prop for cases where multiple notifications may need to render. `aria-describedby` prop must be undefined in this case.
3. Pass a `state` value string and pass a string to the `errorMessage` prop or `successMessage` prop for cases where only a single notification will ever render. `aria-describedby` prop must be undefined and `stateNotifications` prop must be a string in this case.

## Special Case

### Aria Labels
Expand All @@ -136,4 +140,4 @@ Either `label` or `aria-labelledby` or `aria-label` must be provided a string, o

### Aria Describedby

To use a custom error notification container rather than the default provided in this component, `stateNotifications` will only require a string with the appropriate `state` value. In addition, the `aria-describedby` attribute must be provided with the id of the custom notification container. You can read more about `aria-describedby` [here](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby).
To use a custom error notification container rather than the state notifications array or default error or success message provided in this component, `stateNotifications` requires a string with the appropriate `state` value. In addition, the `aria-describedby` attribute must be provided with the id of the custom notification container. You can read more about `aria-describedby` [here](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby).

0 comments on commit 2cf7805

Please sign in to comment.