How to use the @rmwc/toggleable.useToggleFoundation function in @rmwc/toggleable

To help you get started, we’ve selected a few @rmwc/toggleable 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 jamesmfriedman / rmwc / src / checkbox / foundation.tsx View on Github external
export const useCheckboxFoundation = (
  props: CheckboxProps & React.HTMLProps
) => {
  const { renderToggle, toggleRootProps, id } = useToggleFoundation(props);

  const { foundation, ...elements } = useFoundation({
    props,
    elements: {
      rootEl: true,
      checkboxEl: true
    },
    foundation: ({ rootEl, checkboxEl, getProps }) => {
      return new MDCCheckboxFoundation({
        addClass: (className: string) => rootEl.addClass(className),
        removeClass: (className: string) => rootEl.removeClass(className),
        setNativeControlAttr: (attr: string, value: any) =>
          checkboxEl.setProp(attr as any, value),
        removeNativeControlAttr: (attr: string) =>
          checkboxEl.removeProp(attr as any),
        isIndeterminate: () => !!getProps().indeterminate,

@rmwc/toggleable

RMWC toggle module

MIT
Latest version published 2 months ago

Package Health Score

81 / 100
Full package analysis

Popular @rmwc/toggleable functions