How to use the @react-md/form.useCheckboxState function in @react-md/form

To help you get started, we’ve selected a few @react-md/form examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mlaursen / react-md / packages / documentation / src / components / Demos / Form / TextFieldThemeConfig.tsx View on Github external
const TextFieldThemeConfig: FC = ({
  idPrefix,
  children,
  renderField,
  disableDense,
  disableRightIcon,
}) => {
  const [useLeft, handleLeftChange, setLeftIcon] = useCheckboxState(false);
  const [useRight, handleRightChange, setRightIcon] = useCheckboxState(false);
  const [dense, handleDenseChange, setDense] = useCheckboxState(false);
  const [label, handleLabelChange, setLabel] = useCheckboxState(true);
  const [inline, handleInlineChange] = useCheckboxState(false);
  const [readOnly, handleReadOnlyChange, setReadOnly] = useCheckboxState(false);
  const [error, handleErrorChange, setError] = useCheckboxState(false);
  const [disabled, handleDisabledChange] = useCheckboxState(false);
  const [currentTheme, handleThemeChange] = useChoice(
    "outline",
    event => {
      // the "unstyled" state does not support icons and a label out of the box
      // and requires additional styling instead
      if (event.currentTarget.value === "none") {
        setLeftIcon(false);
        setRightIcon(false);
        setLabel(false);
      } else if (!label) {
        setLabel(true);
      }
github mlaursen / react-md / packages / documentation / src / components / Demos / Form / TextFieldThemeConfig.tsx View on Github external
const TextFieldThemeConfig: FC = ({
  idPrefix,
  children,
  renderField,
  disableDense,
  disableRightIcon,
}) => {
  const [useLeft, handleLeftChange, setLeftIcon] = useCheckboxState(false);
  const [useRight, handleRightChange, setRightIcon] = useCheckboxState(false);
  const [dense, handleDenseChange, setDense] = useCheckboxState(false);
  const [label, handleLabelChange, setLabel] = useCheckboxState(true);
  const [inline, handleInlineChange] = useCheckboxState(false);
  const [readOnly, handleReadOnlyChange, setReadOnly] = useCheckboxState(false);
  const [error, handleErrorChange, setError] = useCheckboxState(false);
  const [disabled, handleDisabledChange] = useCheckboxState(false);
  const [currentTheme, handleThemeChange] = useChoice(
    "outline",
    event => {
      // the "unstyled" state does not support icons and a label out of the box
      // and requires additional styling instead
      if (event.currentTarget.value === "none") {
        setLeftIcon(false);
        setRightIcon(false);
        setLabel(false);
      } else if (!label) {
        setLabel(true);
      }
    }
github mlaursen / react-md / packages / documentation / src / components / Demos / Overlay / FixingOverflowIssues.tsx View on Github external
const FixingOverflowIssues: FC = () => {
  const [visible, , disable, toggle] = useToggle(false);
  const [portal, handlePortalChange] = useCheckboxState(false);
  return (
    
      
        
      
      <div>
        </div>
github mlaursen / react-md / packages / documentation / src / components / Demos / Form / NativeSelectExample.tsx View on Github external
const NativeSelectExample: FC = () =&gt; {
  const [icon, handleIconChange, setIcon] = useCheckboxState(true);
  const [size, handleSizeChange] = useChoice("4");
  const [multiple, handleMultipleChange] = useCheckboxState(false);
  const [optgroup, handleOptgroupChange] = useCheckboxState(false);
  if (multiple &amp;&amp; icon) {
    setIcon(false);
  }

  return (
github mlaursen / react-md / packages / documentation / components / Demos / Form / AsyncSwitchExample.tsx View on Github external
const AsyncSwitchExample: FC = () =&gt; {
  const [loading, setLoading] = useState(false);
  const [checked, setChecked] = useState(false);
  const [fail, handleFailChange] = useCheckboxState(false);
  const [start] = useTimeout(() =&gt; {
    setLoading(false);
    if (fail) {
      setChecked(prevChecked =&gt; !prevChecked);
    }
  }, 5000);

  return (
github mlaursen / react-md / packages / documentation / src / components / Demos / Tabs / PersistentTabs / PersistentTabs.tsx View on Github external
const PersistentTabs: FC = () =&gt; {
  const [persistent, handleChange] = useCheckboxState(false);
  return (
github mlaursen / react-md / packages / documentation / components / Demos / Form / TextAreaExample.tsx View on Github external
const TextAreaExample: FC = () =&gt; {
  const [resize, handleResizeChange] = useChoice("auto");
  const [animate, handleAnimateChange] = useCheckboxState(true);
  const [rows, handleRowChange] = useChoice("2");
  const [maxRows, handleMaxRowChange, setMaxRows] = useChoice("-1");
  const rowsInt = parseInt(rows, 10);
  const maxRowsInt = parseInt(maxRows, 10);
  if (maxRowsInt !== -1 &amp;&amp; maxRowsInt &lt; rowsInt) {
    const i = MAX_ROWS.find(value =&gt; value &gt;= rowsInt) || -1;
    setMaxRows(`${i}`);
  }

  return (
     (
github mlaursen / react-md / packages / documentation / components / Demos / Transition / CrossFadeExamples / AsyncPageTransitions.tsx View on Github external
const AsyncPageTransitions: FC = () =&gt; {
  const [checked, onChange] = useCheckboxState(false);
  const [page, setPage] = useState&lt;0 | 1 | 2 | 3&gt;(0);
  const Content = useFakeLazyImport(
    CurrentPage,
    page,
    checked ? 0 : 5000
  );

  return (
github mlaursen / react-md / packages / documentation / components / Demos / Form / CustomCheckboxes.tsx View on Github external
const CustomCheckbox: FC = ({
  defaultChecked = false,
  onChange: propOnChange,
  ...props
}) =&gt; {
  const [checked, onChange] = useCheckboxState(defaultChecked, propOnChange);

  return (
     : }
      disableIconOverlay
    /&gt;
  );
};
github mlaursen / react-md / packages / documentation / src / components / Demos / Form / NativeSelectExample.tsx View on Github external
const NativeSelectExample: FC = () =&gt; {
  const [icon, handleIconChange, setIcon] = useCheckboxState(true);
  const [size, handleSizeChange] = useChoice("4");
  const [multiple, handleMultipleChange] = useCheckboxState(false);
  const [optgroup, handleOptgroupChange] = useCheckboxState(false);
  if (multiple &amp;&amp; icon) {
    setIcon(false);
  }

  return (
     (

@react-md/form

This package is for creating all the different form input types.

MIT
Latest version published 9 months ago

Package Health Score

66 / 100
Full package analysis