packages/react-components/react-label/library/docs/Spec.md
Labels provide a name or title to a component or group of components, e.g., text fields, checkboxes, radio buttons, and dropdown menus.
<Label required>I am a required label</Label>
Props used in v8 Label:
| Prop | Description |
|---|---|
| as | Element type to render Label as |
| componentRef | Optional callback to access the ILabel interface. Use this instead of ref for accessing the public methods and properties of the component |
| disabled | Renders label as disabled, changing the Label's foreground color |
| required | Renders an asterisk next to the given text |
| styles | Custom styles for the Label |
| theme | Theme provided by HOC |
<Label content="You have 23 emails" />
Props used in v0 Label:
| Prop | Description |
|---|---|
| accessibility | Prop to override accessibility behavior |
| as | Element type to render Label as |
| circular | Renders Label with round corners |
| className | Additional CSS class name to apply |
| color | Color for the background of the label |
| content | Label content |
| fluid | Make it so Label takes the width of its container |
| icon | Adds an icon to the label |
| iconPosition | Choose where the icon is placed (Start or End) |
| image | Adds an image to the label |
| imagePosition | Choose where the image is placed (Start or End) |
| styles | Additional custom styles for the component |
| variables | Allows override of theme variables |
Moving forward, Label will be a simple component. The converged Label will be based on v8's Label with some minor changes. Most props from v0 will be left out but because of the use of slots, it won't be too difficult to migrate to the converged Label.
The Label component should be simple as shown below. It will just need the text to be rendered. For the required label, it has the option of being a shorthand slot that will allow to customize the label's required text.
<Label>Label</Label>
<Label disabled>Label</Label>
<Label required>Label</Label>
<Label required="**">
Label
</Label>
required.See API at Label.types.ts.
<Label required>I'm a Label</Label>
<label class="...">
I'm a Label
<span class="...">*</span>
</label>
<slots.root {...slotProps.root}>
{state.children}
<slots.required {...slotProps.required} />
</slots.root>
See MIGRATION.md
Label does not have state attributes.
Keyboard, Cursor, Touch, and Screen Readers
label element to render.