Label
A form label. Wrap a control in it, or point it at one with `for`.
Install
If this is the first component in the project, set up once. This writes ermine.json and copies the theme stylesheet. The installation guide covers Vue, Nuxt and Astro.
npx ermineui initpnpm dlx ermineui inityarn dlx ermineui initbunx ermineui initThen add the component:
npx ermineui add labelpnpm dlx ermineui add labelyarn dlx ermineui add labelbunx ermineui add labelThat copies 2 files into src/components/ui/label/. Files you already have are kept.
Use
import { Label } from '@/components/ui/label'<script setup lang="ts">
import { Label } from '@/components/ui/label'
</script>
<template>
<Label />
</template>In Nuxt, with the auto-import setting, the tags work in templates without the import. In Astro, use it inside a Vue island. The props are documented in the source below, on each one.
What gets copied
| File | Where it goes |
|---|---|
Label.vue | src/components/ui/label/Label.vue |
index.ts | src/components/ui/label/index.ts |
The folders are the suggested ones. ermine.json says where yours are.
Source
This is exactly what the command copies. To install by hand, create each file below and the helpers listed above.
Label.vue 25 lines
<template>
<label class="er-label"><slot /></label>
</template>
<style>
@layer components {
.er-label {
display: flex;
align-items: center;
gap: 0.5rem;
color: var(--er-foreground);
font-size: 0.875rem;
font-weight: var(--er-weight-medium);
line-height: 1.25;
user-select: none;
}
/* Dim the label when the control it wraps is disabled. */
.er-label:has(:disabled) {
opacity: 0.6;
cursor: not-allowed;
}
}
</style>index.ts 3 lines
/** Label — a form label. Wrap a control in it, or point it at one with `for`. */
export { default as Label } from './Label.vue'