Label
octane/labelFreeComponent
octane publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by octane on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://raw.githubusercontent.com/octanejs/octane/main/packages/shadcn/registry/label.jsonSource
1// Base UI base label — a plain host `<label>`.2//3// NOT `Field.Label`, and that is the whole point of this file. Base UI's label part is4// `Field.Label`, but it calls `useFieldRootContext(false)` — it HARD-REQUIRES a `<Field.Root>`5// ancestor and throws "FieldRootContext is missing" without one. Upstream's own FieldLabel does6// the same, so that is faithful behavior, not a porting defect.7//8// shadcn's `Label`, by contrast, is a standalone component: the docs use it beside an Input with9// no Field wrapper at all, which is exactly how the playground uses it. Routing it through10// `Field.Label` made every such use a runtime crash. A plain `<label>` works standalone AND11// inside a Field, and consumers who want Base UI's automatic label/control association can reach12// for `Field.Label` directly.13//14// Regression coverage: `tests/base-ui-standalone.test.ts`.15//16// UNVERIFIED PROVENANCE: the class string is taken from this package's React Aria base rather17// than transcribed from upstream's Base UI source. It carries one utility the Radix base omits18// (`peer-data-disabled:opacity-50`).19import { cn } from '@/lib/utils';20import type { HostProps } from '@/lib/types';2122export function Label({ className, ...props }: HostProps<'label'>) @{23 <label24 data-slot="label"25 className={cn(26 'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 peer-data-disabled:opacity-50',27 className,28 )}29 {...props}30 />31}
What it pulls in
Other registry items
Files it writes
More from octane
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | octane | Components | Free | 2 deps | |
| Alertalert | octane | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | octane | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | octane | Components | Free | no deps | |
| Avataravatar | octane | Components | Free | 1 dep | |
| Badgebadge | octane | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | octane | Components | Free | 1 dep | |
| Buttonbutton | octane | Components | Free | 2 deps |
