Label
Form field label with required indicator and floating state support.
Aperçu
Rendu de l’aperçu en cours…
defaultRendu de l’aperçu en cours…
requiredRendu de l’aperçu en cours…
primaryRendu de l’aperçu en cours…
dangerStructure
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<origam-label> — 2 internal parts. The required indicator ② is a <sup>*</sup> appended when required=true.- 1.origam-label
- Root element. Renders as
<label>by default. Acceptstagoverride. - 2.origam-label sup
- Required indicator
<sup>*</sup>. Only rendered whenrequired=true. Color driven by--origam-label---required-indicator-color.
API
Props
Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.
- textstring
- Label text content. Can also be set via the default slot.
- floatingbooleanfalse
- Activates the floating label variant (smaller font-size, hidden by default until field activation).
- requiredbooleanfalse
- Appends a <sup>*</sup> required indicator after the label text.
- namestring
- HTML name attribute forwarded to the root element.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- marginboolean | number | string
- CSS margin shorthand applied via the margin composable.
- marginTopboolean | number | string
- marginLeftboolean | number | string
- marginBottomboolean | number | string
- marginRightboolean | number | string
- marginBlockboolean | number | string
- marginInlineboolean | number | string
- marginInlineStartboolean | number | string
- marginInlineEndboolean | number | string
- marginBlockStartboolean | number | string
- marginBlockEndboolean | number | string
- paddingboolean | number | string
- CSS padding shorthand applied via the padding composable.
- paddingTopboolean | number | string
- paddingLeftboolean | number | string
- paddingBottomboolean | number | string
- paddingRightboolean | number | string
- paddingBlockboolean | number | string
- paddingInlineboolean | number | string
- paddingInlineStartboolean | number | string
- paddingInlineEndboolean | number | string
- paddingBlockStartboolean | number | string
- paddingBlockEndboolean | number | string
- borderboolean | number | string | TDirectionBoth | Array<TDirectionBoth>false
- Applies a border. Pass true for the default border or a CSS shorthand.
- borderTopboolean | number | string
- borderLeftboolean | number | string
- borderBottomboolean | number | string
- borderRightboolean | number | string
- borderBlockboolean | number | string
- borderInlineboolean | number | string
- borderInlineStartboolean | number | string
- borderInlineEndboolean | number | string
- borderBlockStartboolean | number | string
- borderBlockEndboolean | number | string
- borderColorstring
- borderStylestring
- borderTopColorTColor
- borderRightColorTColor
- borderBottomColorTColor
- borderLeftColorTColor
- borderInlineStartColorTColor
- borderInlineEndColorTColor
- borderBlockStartColorTColor
- borderBlockEndColorTColor
- Border-radius token or boolean.
- roundedTopRightboolean | number | string
- roundedTopLeftboolean | number | string
- roundedBottomLeftboolean | number | string
- roundedBottomRightboolean | number | string
- roundedStartStartboolean | number | string
- roundedStartEndboolean | number | string
- roundedEndStartboolean | number | string
- roundedEndEndboolean | number | string
- color
- Foreground (text) color. Accepts semantic intents or a CSS color.
- bgColor
- Background color override.
- tagstring'label'
- HTML element rendered at root. Defaults to <label>.
- fontSizeTFontSize
- fontWeightTFontWeight
- lineHeightTLineHeight
- letterSpacingTLetterSpacing
API
Slots
Emplacements de contenu exposés par ce composant.
- #default
- Main label content. Overrides the text prop. The required indicator <sup>*</sup> is appended after the slot when required=true.
API
Emits
Événements émis par ce composant.
- @clickMouseEvent
- Fired when the label element is clicked.
API
Membres exposés
Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.
- <T extends object>(props: T, exclude?: string[]) => Partial<T>
- Utility to forward a filtered subset of props to a child component.
- Ref<string>
- Reactive CSS string generated by useStyle.
- string
- Unique style-sheet ID for this instance.
- () => void
- Injects the computed style sheet into the document.
- () => void
- Removes the injected style sheet.
- Ref<boolean>
- True once the style sheet has been injected into the DOM.
Personnalisation
Variables CSS
Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.
- Default label text color.
- Default font size. Overridden to 1em when used inside OrigamField.
- Label font weight.
- Label line height.
- Label letter spacing.
- Labels do not capture pointer events (positioned on top of input).
- Duration of opacity/transform transitions for the float animation.
- Color of the asterisk required indicator <sup>*</sup>.
- Font size of the floating variant (clone shown in the field notch).
Inclusion
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
Rôles ARIA
Interactions clavier
| Touche | Action |
|---|---|
| click on label | Clicking the label focuses its associated input (native <label> for= binding). |
Notes
- Use the for= attribute (via id matching) or wrap the input inside the label to associate them. The component does not auto-generate the for= relationship.
- The <sup>*</sup> required indicator is a visual cue only. Screen readers may not announce it. Pair with aria-required="true" on the input for complete accessibility.
Fondation
Design tokens
Extrait des tokens de ce composant — les variables --origam-<composant>---<propriété>, déclarées dans sa feuille de tokens tenue à la main, sans étape de build.
- colorvar(--origam-color__text---secondary)
- Default label text color.
- dimensionvar(--origam-font__size---md)
- Default font size.
- fontWeightvar(--origam-font__weight---regular)
- Label font weight.
- durationvar(--origam-motion__duration---normal)
- Duration of float animation transitions.
- colorvar(--origam-color__feedback--danger---fgSubtle)
- Color of the asterisk required indicator.
Interactif
Playground
Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.
Rendu de l’aperçu en cours…
Usage
Exemples
Extraits de code prêts à coller dans vos templates.
Basic label
Required field
Color variants