MYDS Logo

    MYDS

    Beta

    Label

    The Label component is a standardized form element used to associate descriptive text with controls such as checkboxes and toggles. This component ensures accessibility and consistent styling for Malaysian government websites.

    Usage

    import { Label } from "@govtechmy/myds-react/label";
    import { Checkbox } from "@govtechmy/myds-react/checkbox";
    import { Toggle, ToggleThumb } from "@govtechmy/myds-react/toggle";
    export default () => (
      <>
        <div className="flex items-center justify-between">
          <Label htmlFor="checkbox">Auto-delete notifications</Label>
          <Checkbox id="checkbox"></Checkbox>
        </div>
        <div className="flex items-center justify-between">
          <Label htmlFor="toggle">Enable 2FA security?</Label>
          <Toggle id="toggle">
            <ToggleThumb />
          </Toggle>
        </div>
      </>
    );

    Examples

    Size

    Use the size prop to change the label size!

    Using as Slot

    Use the asChild prop to render the label using the Slot component!

    Custom Rendered Label

    Props

    LabelProps

    PropTypeDefault
    asChild
    boolean
    false
    size
    enum
    medium
    className
    string
    -

    On this page