@react-md/form
Version:
This package is for creating all the different form input types.
50 lines (49 loc) • 1.84 kB
TypeScript
import type { HTMLAttributes } from "react";
/**
* @remarks \@since 2.5.0
*/
export interface LabelStates {
/**
* Boolean if the label should gain the error state.
*/
error?: boolean;
/**
* Boolean if the label should gain the disabled state.
*/
disabled?: boolean;
/**
* Boolean if the label should gain the active state. This should normally be
* enabled whenever the `<input>`/`<textarea>` gain focus. This is really more
* for text input than anything else, and probably shouldn't be used for
* checkbox, radio or switch components.
*/
active?: boolean;
}
export interface LabelProps extends HTMLAttributes<HTMLLabelElement>, LabelStates {
/**
* An id for the `<input>` or `<textarea>` that this label is for. This is
* required since all label's **should** point to a valid
* `<input>`/`<textarea>`.
*/
htmlFor: string;
/**
* The component to render the label as. This should be the default value of
* `"label"` 99% of the time, but can also be rendered as a `"span"` for the
* `Select` implementation where it needs to be rendered in a button.
*/
component?: "label" | "span";
}
/**
* A simple util that can generate all the "valid" styles for a label. This
* shouldn't really be used, but it's useful if you want the label styles
* without rendering a `<label>` element.
*
* @remarks \@since 2.5.0
* @internal
*/
export declare const labelStyles: ({ error, active, disabled, }?: LabelStates) => string;
/**
* The `Label` component should be used alongside any form elements but is
* already built in to the majority of the `react-md` components by default.
*/
export declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLLabelElement>>;