跳转到内容

FormLabel API

API documentation for the React FormLabel component. Learn about the available props, and the CSS API.

Import

import FormLabel from '@material-ui/core/FormLabel';
// or
import { FormLabel } from '@material-ui/core';
You can learn about the difference by reading this guide on minimizing bundle size.

Component name

The name MuiFormLabel can be used when providing default props or style overrides in the theme.

Props

NameTypeDefaultDescription
childrennodeThe content of the component.
classesobjectOverride or extend the styles applied to the component. See CSS API below for more details.
color'primary'
| 'secondary'
The color of the component. It supports those theme colors that make sense for this component.
componentelementTypeThe component used for the root node. Either a string to use a HTML element or a component.
disabledboolfalseIf true, the label should be displayed in a disabled state.
errorboolfalseIf true, the label should be displayed in an error state.
filledboolfalseIf true, the label should use filled classes key.
focusedboolfalseIf true, the input of this label is focused (used by FormGroup components).
requiredboolfalseIf true, the label will indicate that the input is required.

The ref is forwarded to the root element.
Any other props supplied will be provided to the root element (native element).

CSS

Rule nameGlobal classDescription
root.MuiFormLabel-rootStyles applied to the root element.
colorSecondary.MuiFormLabel-colorSecondaryStyles applied to the root element if the color is secondary.
focused.Mui-focusedPseudo-class applied to the root element if focused={true}.
disabled.Mui-disabledPseudo-class applied to the root element if disabled={true}.
error.Mui-errorPseudo-class applied to the root element if error={true}.
filled.MuiFormLabel-filledPseudo-class applied to the root element if filled={true}.
required.Mui-requiredPseudo-class applied to the root element if required={true}.
asterisk.MuiFormLabel-asteriskStyles applied to the asterisk element.

You can override the style of the component using one of these customization options: If that isn't sufficient, you can check the implementation of the component for more detail.

Demos