import { jsx, jsxs, Fragment } from 'solid-jsx/jsx-runtime';

/*@jsxRuntime automatic @jsxImportSource solid-jsx*/
const toc = [];
function _createMdxContent(props) {
  const _components = Object.assign({
    p: "p",
    code: "code",
    pre: "pre",
    span: "span"
  }, props.components);
  return jsxs(Fragment, {
    children: [jsxs(_components.p, {
      children: ["Solid uses ", jsx(_components.code, {
        children: "class"
      }), " to set the ", jsx(_components.code, {
        children: "className"
      }), " property on an element. However it is often convenient to conditionally set classes. For that reason, Solid has a built-in ", jsx(_components.code, {
        children: "classList"
      }), " JSX attribute that takes an object where the key is the class name(s) and the value is a boolean expression. When true, the class is applied, and when false, it is removed."]
    }), "\n", jsx(_components.p, {
      children: "In the example, we can replace:"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: ["<button\n  ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "class"
        }), "={", jsx(_components.span, {
          className: "hljs-title function_",
          children: "current"
        }), "() === ", jsx(_components.span, {
          className: "hljs-string",
          children: "'foo'"
        }), " ? ", jsx(_components.span, {
          className: "hljs-string",
          children: "'selected'"
        }), " : ", jsx(_components.span, {
          className: "hljs-string",
          children: "''"
        }), "}\n  onClick={", jsx(_components.span, {
          className: "hljs-function",
          children: "() =>"
        }), " ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "setCurrent"
        }), "(", jsx(_components.span, {
          className: "hljs-string",
          children: "'foo'"
        }), ")}\n>foo</button>\n"]
      })
    }), "\n", jsx(_components.p, {
      children: "with:"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: ["<button\n  classList={{", jsx(_components.span, {
          className: "hljs-attr",
          children: "selected"
        }), ": ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "current"
        }), "() === ", jsx(_components.span, {
          className: "hljs-string",
          children: "'foo'"
        }), "}}\n  onClick={", jsx(_components.span, {
          className: "hljs-function",
          children: "() =>"
        }), " ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "setCurrent"
        }), "(", jsx(_components.span, {
          className: "hljs-string",
          children: "'foo'"
        }), ")}\n>foo</button>\n"]
      })
    }), "\n", jsx(_components.p, {
      children: "Remember that you can apply names dynamically like what you'd receive in CSS modules as well:"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "import"
        }), " { active } ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "from"
        }), " ", jsx(_components.span, {
          className: "hljs-string",
          children: "\"./style.module.css\""
        }), "\n\n<div classList={{ [active]: ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "isActive"
        }), "() }} />\n"]
      })
    })]
  });
}
function MDXContent(props = {}) {
  const {wrapper: MDXLayout} = props.components || ({});
  return MDXLayout ? jsx(MDXLayout, Object.assign({}, props, {
    children: jsx(_createMdxContent, props)
  })) : _createMdxContent(props);
}

export { MDXContent as default, toc };
//# sourceMappingURL=lesson-13fa758a.js.map
