Label
A <label>: a caption for another element
Code
<script lang="ts">
import { Label } from '@geoffcox/sterling-svelte';
</script>
<Label>sterling-svelte</Label>
Members
| Property Name | Type | Default | Comment | | forwardClick | string | false |
| message | string | '' |
| required | string | false |
| requiredReason | string | '' |
| status | string | '' |
| text | string | '' |
| vertical | string | true |
| variant | string | '' |
Types
| Type Name | Definition | Comment | | LabelStatus | 'none' | 'error' | 'warning' | 'info' | 'success' |
Considerations
- An optional message and status can provide information to the user about their value.
- The required property and requiredReason indicate the user must fill in a value and why.
- Includes HTMLLabelElement props, event, and methods
Anatomy
<label class="sterling-label">
<slot name="text" {disabled} {for} {forwardClick} {required} {text} {variant}>
<div class="text">{text}</div>
</slot>
<div class="content">
<slot />
</div>
<slot name="message" {disabled} {message} {required} {status} {variant}>
<div class="message">{message}</div>
</slot>
<slot name="required" {requiredReason} {variant}>
<Tooltip>
<span class="required-reason" slot="tip">{requiredReason}</span>
<div class="required">*</div>
</Tooltip>
</slot>
</label>