Label
Accessible label tied to a control with htmlFor.
import { Checkbox } from "@/components/ui/checkbox";import { Label } from "@/components/ui/label";
export default function Demo() { return ( <div className="flex flex-wrap items-center gap-8"> <Label>Index name</Label> <Label> Ticker <span className="text-destructive-text">*</span> </Label> <Label className="items-baseline"> Description{" "} <span className="font-normal text-muted-foreground">(optional)</span> </Label> <div className="flex items-center gap-2"> <Checkbox id="keeper" defaultChecked /> <Label htmlFor="keeper">Allow keeper</Label> </div> </div> );}<script setup lang="ts">import { Checkbox } from "@/components/ui/checkbox";import { Label } from "@/components/ui/label";</script>
<template> <div class="flex flex-wrap items-center gap-8"> <Label>Index name</Label> <Label> Ticker <span class="text-destructive-text">*</span> </Label> <Label class="items-baseline"> Description <span class="font-normal text-muted-foreground">(optional)</span> </Label> <div class="flex items-center gap-2"> <Checkbox id="keeper" default-value="true" /> <Label for="keeper">Allow keeper</Label> </div> </div></template><script lang="ts"> import { Checkbox } from "$lib/components/ui/checkbox"; import { Label } from "$lib/components/ui/label";</script>
<div class="flex flex-wrap items-center gap-8"> <Label>Index name</Label> <Label>Ticker <span class="text-destructive-text">*</span></Label> <Label class="items-baseline"> Description <span class="font-normal text-muted-foreground">(optional)</span> </Label> <div class="flex items-center gap-2"> <Checkbox id="keeper" checked /> <Label for="keeper">Allow keeper</Label> </div></div>Installation
Section titled “Installation”npx shadcn@latest add @edmi-ui/labelpnpm dlx shadcn@latest add @edmi-ui/labelyarn dlx shadcn@latest add @edmi-ui/labelbunx shadcn@latest add @edmi-ui/labelPick your package manager above; the choice is remembered. Add the @edmi-ui registry first, see Getting started.
Copy the code from Component source into your project and update the import paths to match your aliases.
npx shadcn-vue@latest add @edmi-ui/labelpnpm dlx shadcn-vue@latest add @edmi-ui/labelyarn dlx shadcn-vue@latest add @edmi-ui/labelbunx shadcn-vue@latest add @edmi-ui/labelPick your package manager above; the choice is remembered. Add the @edmi-ui registry first, see Getting started.
Install the dependencies:
Terminal window npm install reka-ui @vueuse/coreTerminal window pnpm add reka-ui @vueuse/coreTerminal window yarn add reka-ui @vueuse/coreTerminal window bun add reka-ui @vueuse/coreCopy the code from Component source into your project and update the import paths to match your aliases.
npx shadcn-svelte@latest add https://viandwi24.github.io/edmi-ui/r/svelte/label.jsonpnpm dlx shadcn-svelte@latest add https://viandwi24.github.io/edmi-ui/r/svelte/label.jsonyarn dlx shadcn-svelte@latest add https://viandwi24.github.io/edmi-ui/r/svelte/label.jsonbunx --bun shadcn-svelte@latest add https://viandwi24.github.io/edmi-ui/r/svelte/label.jsonPick your package manager above; the choice is remembered. Add the @edmi-ui registry first, see Getting started.
Copy the code from Component source into your project and update the import paths to match your aliases.
import { Checkbox } from "@/components/ui/checkbox";import { Label } from "@/components/ui/label";
<div className="flex flex-wrap items-center gap-8"> <Label>Index name</Label> <Label> Ticker <span className="text-destructive-text">*</span> </Label> <Label className="items-baseline"> Description{" "} <span className="font-normal text-muted-foreground">(optional)</span> </Label> <div className="flex items-center gap-2"> <Checkbox id="keeper" defaultChecked /> <Label htmlFor="keeper">Allow keeper</Label> </div></div><script setup lang="ts">import { Checkbox } from "@/components/ui/checkbox";import { Label } from "@/components/ui/label";</script>
<template> <div class="flex flex-wrap items-center gap-8"> <Label>Index name</Label> <Label> Ticker <span class="text-destructive-text">*</span> </Label> <Label class="items-baseline"> Description <span class="font-normal text-muted-foreground">(optional)</span> </Label> <div class="flex items-center gap-2"> <Checkbox id="keeper" default-value="true" /> <Label for="keeper">Allow keeper</Label> </div> </div></template><script lang="ts"> import { Checkbox } from "$lib/components/ui/checkbox"; import { Label } from "$lib/components/ui/label";</script>
<div class="flex flex-wrap items-center gap-8"> <Label>Index name</Label> <Label>Ticker <span class="text-destructive-text">*</span></Label> <Label class="items-baseline"> Description <span class="font-normal text-muted-foreground">(optional)</span> </Label> <div class="flex items-center gap-2"> <Checkbox id="keeper" checked /> <Label for="keeper">Allow keeper</Label> </div></div>Component source
Section titled “Component source”"use client";
import { cn } from "cn";import type * as React from "react";
function Label({ className, ...props }: React.ComponentProps<"label">) { return ( // biome-ignore lint/a11y/noLabelWithoutControl: the control is supplied by the consumer (htmlFor or nesting) <label data-slot="label" className={cn( "flex items-center gap-2 text-sm leading-none font-medium text-foreground select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className, )} {...props} /> );}
export { Label };<script setup lang="ts">import type { LabelProps } from 'reka-ui'import type { HTMLAttributes } from 'vue'import { reactiveOmit } from '@vueuse/core'import { Label } from 'reka-ui'import { cn } from '@/registry/edmi/lib/utils'
const props = defineProps<LabelProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = reactiveOmit(props, 'class')</script>
<template> <Label data-slot="label" v-bind="delegatedProps" :class=" cn( 'flex items-center gap-2 text-sm leading-none font-medium text-foreground select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50', props.class, ) " > <slot /> </Label></template>export { default as Label } from "./Label.vue";<script lang="ts"> import { Label as LabelPrimitive } from "bits-ui"; import { cn } from "$lib/utils.js";
let { ref = $bindable(null), class: className, ...restProps }: LabelPrimitive.RootProps = $props();</script>
<LabelPrimitive.Root bind:ref data-slot="label" class={cn( "flex items-center gap-2 text-sm leading-none font-medium text-foreground select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className )} {...restProps}/>import Root from "./label.svelte";
export { Root, // Root as Label,};| Prop | Type | Default |
|---|---|---|
| htmlFor | string |
none |
✦ Edmi additions
Section titled “✦ Edmi additions”- Foreground ink with weight 500; dims when its peer or Field is disabled.