Label
shadcn-lit-registry/labelFreeComponent
Renders an accessible label associated with controls.
Install it
npx shadcn@latest add https://lit-registry.lloydrichards.dev/r/label.jsonSource
1import "../checkbox/checkbox";2import type { Meta, StoryObj } from "@storybook/web-components-vite";3import { html } from "lit";45type LabelArgs = Omit<HTMLLabelElement, "children"> & { children?: string };67const meta: Meta<LabelArgs> = {8 title: "ui/Label",9 component: "label",10 tags: ["autodocs"],11 argTypes: {12 children: {13 control: "text",14 description: "Label text content",15 },16 },17 args: {18 children: "Email",19 },20 parameters: {21 layout: "centered",22 },23 render: (args) => html` <label class="ui-label"> ${args.children} </label> `,24};2526export default meta;27type Story = StoryObj<LabelArgs>;2829export const Default: Story = {};3031export const WithInput: Story = {32 render: (args) => html`33 <div class="grid w-full gap-3">34 <label class="ui-label" for="email">${args.children}</label>35 <input id="email" class="ui-input" placeholder="Enter your email" class="w-96"></input>36 </div>37 `,38};3940export const WithRequiredIndicator: Story = {41 render: (args) => html`42 <div class="grid w-full gap-3">43 <label class="ui-label" for="email">44 ${args.children} <span class="text-destructive">*</span>45 </label>46 <input class="ui-input" type="email" required class="w-96"></input>47 </div>48 `,49};5051export const CustomStyling: Story = {52 render: (args) => html`53 <label class="ui-label text-base font-semibold"> ${args.children} </label>54 `,55 args: {56 children: "Important Field",57 },58};5960export const WithHelperText: Story = {61 render: (args) => html`62 <div class="grid w-full gap-3">63 <label class="ui-label" for="email">${args.children}</label>64 <input id="email" class="ui-input" placeholder="Enter your email" class="w-96"></input>65 <p class="text-sm text-muted-foreground">We'll never share your email.</p>66 </div>67 `,68};6970export const PeerDisabled: Story = {71 render: (args) => html`72 <div class="flex items-center gap-2">73 <ui-checkbox id="checkbox" class="peer" disabled checked></ui-checkbox>74 <label class="ui-label" for="checkbox">${args.children}</label>75 </div>76 `,77 args: {78 children: "Disabled checkbox label",79 },80};
Files it writes
More from shadcn-lit-registry
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | shadcn-lit-registry | Components | Free | 1 dep · 2 files | |
| Avataravatar | shadcn-lit-registry | Components | Free | no deps · 2 files | |
| Badgebadge | shadcn-lit-registry | Components | Free | no deps · 2 files | |
| Buttonbutton | shadcn-lit-registry | Components | Free | 1 dep · 2 files | |
| Cardcard | shadcn-lit-registry | Components | Free | no deps · 2 files | |
| Checkboxcheckbox | shadcn-lit-registry | Components | Free | 1 dep · 2 files | |
| Collapsiblecollapsible | shadcn-lit-registry | Components | Free | 1 dep · 2 files | |
| Commandcommand | shadcn-lit-registry | Components | Free | 1 dep · 2 files |
