Propel

Switch Field

A switch laid out as a field row with label, description, and hint or error text.

Basic

Automatically restart the service after a crash.

You can change this later.

Show code
import { SwitchField } from "@makeplane/propel/components/switch-field";

export default function BasicDemo() {
  return (
    <SwitchField
      name="restartOnFailure"
      label="Restart on failure"
      magnitude="md"
      description="Automatically restart the service after a crash."
      hint="You can change this later."
      defaultChecked
    />
  );
}

Magnitudes

The magnitude axis (sm, md, lg) sizes the switch and scales the label and helper text with it.

Show code
import { SwitchField } from "@makeplane/propel/components/switch-field";

export default function MagnitudesDemo() {
  return (
    <div className="flex flex-col items-start gap-3">
      <SwitchField
        name="autoArchiveSm"
        label="Auto-archive done items"
        magnitude="sm"
        defaultChecked
      />
      <SwitchField
        name="autoArchiveMd"
        label="Auto-archive done items"
        magnitude="md"
        defaultChecked
      />
      <SwitchField
        name="autoArchiveLg"
        label="Auto-archive done items"
        magnitude="lg"
        defaultChecked
      />
    </div>
  );
}

Disabled

Managed by your identity provider.

Disabled for this workspace plan.

Show code
import { SwitchField } from "@makeplane/propel/components/switch-field";

export default function DisabledDemo() {
  return (
    <div className="flex flex-col items-start gap-3">
      <SwitchField
        name="ssoEnforced"
        label="Enforce single sign-on"
        description="Managed by your identity provider."
        magnitude="md"
        defaultChecked
        disabled
      />
      <SwitchField
        name="legacyApi"
        label="Allow legacy API tokens"
        description="Disabled for this workspace plan."
        magnitude="md"
        disabled
      />
    </div>
  );
}

Error

Passing error marks the field invalid and replaces the hint with the error text.

Every member must enable 2FA before joining.

Enable 2FA on your own account before enforcing it for the workspace.
Show code
import { SwitchField } from "@makeplane/propel/components/switch-field";

export default function ErrorDemo() {
  return (
    <SwitchField
      name="requireTwoFactor"
      label="Require two-factor authentication"
      description="Every member must enable 2FA before joining."
      magnitude="md"
      error="Enable 2FA on your own account before enforcing it for the workspace."
    />
  );
}

Controlled

A Monday summary of activity across your projects.

Digest emails are paused.

Show code
import { SwitchField } from "@makeplane/propel/components/switch-field";
import * as React from "react";

export default function ControlledDemo() {
  const [checked, setChecked] = React.useState(false);

  return (
    <SwitchField
      name="weeklyDigest"
      label="Weekly project digest"
      description="A Monday summary of activity across your projects."
      magnitude="md"
      checked={checked}
      onCheckedChange={setChecked}
      hint={checked ? "You will receive the digest every Monday." : "Digest emails are paused."}
    />
  );
}

Installation

import { SwitchField } from "@makeplane/propel/components/switch-field";

Props

SwitchField

PropTypeRequiredDescription
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchRootState>NoAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
magnitude"lg" | "md" | "sm"YesThe switch size axis.
hintReactNodeNoHelper text shown below the control. Replaced by `error` when an error is set.
errorReactNodeNoError text shown below the control.
labelstringYesVisible field label.
descriptionReactNodeNoOptional supporting text announced as the switch description.