Skip to content
Star

Label

A semantic HTML label component that associates text with a form control. Supports an optional required indicator (asterisk) and the for attribute for accessibility.

Basic

Demo

Props

Props
PropTypeDefaultDescription
labelrequiredstringThe text content displayed inside the label element.
forstringundefinedThe id of the associated form control (sets the HTML for attribute).
requiredbooleanfalseWhen true, shows a red asterisk (*) after the label text as a required-field indicator.

Accessibility

  • Uses a native <label> element with a proper for/id association.
  • The asterisk (*) has aria-hidden="true" so screen readers don't read it as literal punctuation. Required state should still be communicated via aria-required on the input.
  • Clicking the label focuses the associated input automatically (native browser behavior).

Migration from PxRequiredLabel

PxRequiredLabel is now deprecated. Replace it with PxLabel:

diff
- import { PxRequiredLabel } from 'praxis-vue-ui'
+ import { PxLabel } from 'praxis-vue-ui'

- <PxRequiredLabel label="Name" :required="true" />
+ <PxLabel label="Name" for="name-input" :required="true" />

Built with VitePress