Skip to content
Open
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions src/runtime/components/input/PasswordToggle.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<script setup lang="ts">
import UButton from '@nuxt/ui/components/Button.vue'
import UInput from '@nuxt/ui/components/Input.vue'
import { ref } from 'vue'
import { ref, useId } from 'vue'

const show = ref(false)
const input = defineModel<string>({ default: '' })
const inputId = useId()
</script>

<template>
<UInput
:id="inputId"
v-model="input"
:type="show ? 'text' : 'password'"
:ui="{ trailing: 'pe-1' }"
Expand All @@ -21,7 +23,7 @@ const input = defineModel<string>({ default: '' })
:icon="show ? 'i-lucide-eye-off' : 'i-lucide-eye'"
:aria-label="show ? 'Hide password' : 'Show password'"
:aria-pressed="show"
aria-controls="password"
:aria-controls="inputId"
@click="show = !show"
/>
</template>
Expand Down
Loading