Label
Form-control label rendered as a native <label>; supports required indicator and disabled colouring.
Renders a native <label>; pair with an input via htmlFor; required marker is aria-hidden.
Preview
tsx
import { Input, Label } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.375rem', width: '260px' }}>
<Label htmlFor="email">Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />
</div>
);
}
Required indicator
Section titled “Required indicator”Set required to append a decorative red asterisk after the label text. The asterisk is aria-hidden; pair with required on the input for assistive tech.
Preview
tsx
import { Input, Label } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.375rem', width: '260px' }}>
<Label htmlFor="username" required>
Username
</Label>
<Input id="username" required placeholder="ada-lovelace" />
</div>
);
}
Disabled
Section titled “Disabled”Set disabled to render the label in the disabled colour. Use this when the associated control is disabled.
Preview
tsx
import { Input, Label } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.375rem', width: '260px' }}>
<Label htmlFor="locked" disabled>
Account ID
</Label>
<Input id="locked" disabled defaultValue="usr_9f2c4" />
</div>
);
}
With a form control
Section titled “With a form control”A Label, Input, and helper text laid out as a typical field.
Preview
tsx
import { HelperText, Input, Label } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.375rem', width: '320px' }}>
<Label htmlFor="handle" required>
Handle
</Label>
<Input id="handle" placeholder="@arshad" aria-describedby="handle-help" />
<HelperText id="handle-help">Letters, numbers, and underscores only.</HelperText>
</div>
);
}
PropTypeDefaultDescription
required
boolean
—
Appends a red `*` after the label text. Purely decorative (`aria-hidden`).
disabled
boolean
—
Renders in the disabled colour.
className
string
—
style
CSSProperties
—
Accessibility
Section titled “Accessibility”- Renders a native
<label>element; inherits all built-in semantics. - Use
htmlForto associate the label with its control byid. - Clicking the label transfers focus to the associated form field.
- The required indicator is purely visual (
aria-hidden); mirror the state on the input.
Recipes
Section titled “Recipes”- Pair every input, select, or textarea with a Label for screen-reader users.
- Use a visually hidden label when the visual design omits a caption.
- When using
Fieldsetfor a group, prefer itslegendover a free-standing Label.