Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e87cfe8
Show password example
hannahiss Mar 4, 2026
30e5c71
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Mar 5, 2026
6e17d91
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Mar 9, 2026
6bee9aa
Use sprite for show/hide password icon
hannahiss Mar 9, 2026
1963c9e
Doc
hannahiss Mar 9, 2026
e344b5d
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Mar 9, 2026
a5ace19
Right name for icon - oups
hannahiss Mar 9, 2026
2e86994
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Mar 12, 2026
555ebab
Navigation buttons full doc with styles and icons
hannahiss Mar 12, 2026
43f42fd
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Mar 18, 2026
22125eb
Password input live example
hannahiss Mar 18, 2026
842e7ec
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Mar 19, 2026
7f0be2e
Live example inside input password page
hannahiss Mar 19, 2026
e5b9474
Live example inside input password page
hannahiss Mar 19, 2026
8a4f21c
.
hannahiss Mar 19, 2026
df0cfaf
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Mar 20, 2026
62a071e
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Mar 23, 2026
fe863bc
Change link
hannahiss Mar 23, 2026
f4309a6
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Apr 2, 2026
a3589ce
Merge branch 'ouds/main' into ouds/main-his-show-passwd
hannahiss Apr 8, 2026
01b9a58
missing type="button"
hannahiss Apr 8, 2026
5fed7da
missing type="button" + aria-pressed="false"
hannahiss Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions site/data/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
description: 'Use loading buttons in an accessible way.'
- name: Download app
description: 'A way to illustrate a download app page.'
- name: Show password
description: 'A show/hide password button.'

- category: 'Bootstrap examples'
bootstrap: true
Expand Down
47 changes: 47 additions & 0 deletions site/src/assets/examples/show-password/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
import JsDocs from '@components/shortcodes/JsDocs.astro'
import { getVersionedDocsPath } from '@libs/path'

export const title = 'Show password'
export const extra_css = ['show-password.css']
export const extra_js = [{src: 'show-password.js'}]
export const aliases = [
'/examples/show-password',
'/docs/examples/show-password'
]
---

<main class="container-fluid container-max-width">
<h1 class="py-medium">Show password button</h1>

<p>Find here an example of how to implement a password input with a show password button, show/hide the password value and manage the button icon and label, in an accessible way.</p>

<div class="text-input mb-medium component-max-width">
<div class="text-input-container">
<label for="inputPassword">Password</label>
<input type="password" id="inputPassword" class="text-input-field" placeholder=" ">
<button class="btn btn-minimal btn-icon" id="togglePassword">
<svg aria-hidden="true">
<use xlink:href={getVersionedDocsPath('/assets/img/ouds-web-sprite.svg#accessibility-vision')}/>
</svg>
<span class="visually-hidden">Show password</span>
</button>
</div>
</div>

<div class="accordion" id="code-accordion">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
See Javascript code
</button>
</h2>
<div id="collapseOne" class="accordion-collapse collapse" data-bs-parent="#code-accordion">
<div class="accordion-body border border-subtle p-none">
<JsDocs name="show-password" file="site/src/assets/examples/show-password/show-password.js" />
</div>
</div>
</div>
</div>

</main>
15 changes: 15 additions & 0 deletions site/src/assets/examples/show-password/show-password.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.accordion-item {
max-width: 55rem;
}

.accordion-body {
margin-bottom: 5rem;
}

.accordion-body .highlight {
padding: 24px 24px 0;
}

.accordion-collapse {
background-color: var(--bs-color-bg-secondary);
}
30 changes: 30 additions & 0 deletions site/src/assets/examples/show-password/show-password.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// js-docs-start show-password
// Manage show password button
(() => {
'use strict'
// Toggle password visibility
const togglePasswordButton = document.querySelector('#togglePassword')
if (togglePasswordButton) {
const passwordInput = document.querySelector('#inputPassword')
const iconUse = togglePasswordButton.querySelector('use')
const visuallyHiddenText = togglePasswordButton.querySelector('.visually-hidden')

togglePasswordButton.addEventListener('click', event => {
event.preventDefault()

// Toggle the type attribute to make the password visible or hidden
const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password'
passwordInput.setAttribute('type', type)

// Toggle the icon, the visually-hidden text for accessibility reasons
if (type === 'text') {
iconUse.setAttribute('xlink:href', iconUse.getAttribute('xlink:href').replace('accessibility-vision', 'hide'))
visuallyHiddenText.textContent = 'Hide password'
} else {
iconUse.setAttribute('xlink:href', iconUse.getAttribute('xlink:href').replace('hide', 'accessibility-vision'))
visuallyHiddenText.textContent = 'Show password'
}
})
}
})()
// js-docs-end show-password
2 changes: 2 additions & 0 deletions site/src/content/docs/components/password-input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ A `placeholder` attribute is required on each `<input>` as our CSS-only floating
All other available features of the text input component can be used with the password input, such as leading icons, helper text, and validation states. Please refer to the [text input documentation]([[docsref:/components/text-input]]) for more details.
</Callout>

You will need to write some additional JavaScript code to make the show/hide password button work properly: change the icon and the input type to display the password. You can find a complete example in our [show password live example]([[docsref:/examples/show-password/]]).

<Example buttonLabel="all variations of password input" code={`<div class="text-input mb-medium">
<div class="text-input-container">
<label for="inputPassword">Password</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Now you should write:
</button>
```

You will have to make some extra Javascript to change the styles and update the status message like explained in the documentation. You can find a complete example in our [loading buttons live example]([[docsref:/examples/loading-buttons/]]).
You will have to make some extra JavaScript to change the styles and update the status message like explained in the documentation. You can find a complete example in our [loading buttons live example]([[docsref:/examples/loading-buttons/]]).

</div>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading