{"bugs":{"url":"https://github.com/solidjs-community/solid-aria/issues"},"dist":{"shasum":"0b4c9a91b5fe07a240076c6603c371f95baa97ff","tarball":"https://registry.npmjs.org/@solid-aria/checkbox/-/checkbox-0.0.0-snapshot-20220617074250.tgz","fileCount":4,"integrity":"sha512-auEPrsrTn0+IMJQRZ7P0shh42Icoz/GIyDCHo2wbkfvNIjdxQwdyMBidjQ35BRgwr3Ql9lqBrkGO5kHSIWHobQ==","signatures":[{"sig":"MEQCIG7DDUsdrU2ZNs+zCDmK+lWGm8nL9CmUBx+fDEFVYogEAiBGGlzxtcSXH3bzM5xwc7Q+YU4PMAuN4DpsN5yxak+xrA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17109,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJirDG8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpY5Q/+Mb+iAKsqoIS6zsA2UPdSKDbuyj+OHlTI9WiqQBRk8h2aFzyo\r\n3ENZ6Y4l1vaFyKsNlCY9DYmQmjm8H25fVyS5hW+UhVOtL1C0Ukio+RVZEGmv\r\nItQ8NB4wJ4khFF8FF+7O5NF22SVb4NSmnV33UguFcArY7V8pU/6DFTOBV27j\r\nCcltxI+5XYgNk0UN5byXHUAEroaqo0PZ1kzwZ2JLYFRzfr9IyZwdlPAbR9BK\r\nDWoGkOKdLTsw1T6JWPN3/ZBGwRvmpK5hA8EnpVkBgKCohnLnT4dIGOoHnN7K\r\n3NX8RseT8tod5DCZoC+1qadbZHmjkD1NDDLpfxL+bdUcRO+XBVbM9zBqkJV1\r\nmOOjEwZtD4RwX7xb5ws0kWU23t2TRC0gpGx0NeEahAT5atNFlH6mKbzRqXqU\r\nxt/XvuvYXv0mPYdZ0V/9s6kNULdTXmR6ErIaiPNF9rNDqYYfkkHe1CfwnG+P\r\nJUTOc/sLxwWgxnOSwvPhkIzFpt6smLx4DWQxW10ocnQFVvZBpRXSHqqvVFSJ\r\nld2HmlN8yF7OfdBju1eQiZ93gIM+HCLScfYY0sGdCATVibvqFrQOxua60kRf\r\n7VgqlLNY3dc8Ipx6GRgkqYxQO74ZU2fhbVCOWEH41yxavJczyoq8X3LlNjKr\r\nbsX8x3AFol6mGbiXqwXnyCzLKLDgYmPL2ro=\r\n=qmkY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.cjs","name":"@solid-aria/checkbox","type":"module","types":"dist/index.d.ts","author":{"name":"Fabien Marie-Louise","email":"fabienml.dev@gmail.com"},"module":"dist/index.js","readme":"<p>\n  <img width=\"100%\" src=\"https://assets.solidjs.com/banner?type=Aria&background=tiles&project=Checkbox\" alt=\"Solid Aria - Checkbox\">\n</p>\n\n# @solid-aria/checkbox\n\n[![pnpm](https://img.shields.io/badge/maintained%20with-pnpm-cc00ff.svg?style=for-the-badge&logo=pnpm)](https://pnpm.io/)\n[![turborepo](https://img.shields.io/badge/built%20with-turborepo-cc00ff.svg?style=for-the-badge&logo=turborepo)](https://turborepo.org/)\n[![size](https://img.shields.io/bundlephobia/minzip/@solid-aria/checkbox?style=for-the-badge&label=size)](https://bundlephobia.com/package/@solid-aria/checkbox)\n[![version](https://img.shields.io/npm/v/@solid-aria/checkbox?style=for-the-badge)](https://www.npmjs.com/package/@solid-aria/checkbox)\n[![stage](https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fsolidjs-community%2Fsolid-primitives%2Fmain%2Fassets%2Fbadges%2Fstage-0.json)](https://github.com/solidjs-community/solid-aria#contribution-process)\n\nCheckboxes allow users to select multiple items from a list of individual items, or to mark one individual item as selected.\n\n## Installation\n\n```bash\nnpm install @solid-aria/checkbox\n# or\nyarn add @solid-aria/checkbox\n# or\npnpm add @solid-aria/checkbox\n```\n\n## `createCheckbox`\n\nProvides the behavior and accessibility implementation for a checkbox component.\n\n### Features\n\nCheckboxes can be built with the `<input>` HTML element, but this can be difficult to style. `createCheckbox` helps achieve accessible checkboxes that can be styled as needed.\n\n- Built with a native HTML `<input>` element, which can be optionally visually hidden to allow custom styling\n- Full support for browser features like form autofill\n- Keyboard focus management and cross browser normalization\n- Labeling support for assistive technology\n- Indeterminate state support\n\n### How to use it\n\n```tsx\nimport { AriaCheckboxProps, createCheckbox } from \"@solid-aria/checkbox\";\n\nfunction Checkbox(props: AriaCheckboxProps) {\n  let ref: HTMLInputElement | undefined;\n\n  const { inputProps, state } = createCheckbox(props, () => ref);\n\n  return (\n    <label>\n      <input {...inputProps} ref={ref} />\n      <span>{props.children}</span>\n    </label>\n  );\n}\n\nfunction App() {\n  return (\n    <div>\n      <Checkbox>Checkbox</Checkbox>\n      <Checkbox isIndeterminate>Checkbox</Checkbox>\n    </div>\n  );\n}\n```\n\n### Styling\n\nTo build a custom styled checkbox, you can make the native input element visually hidden. This is possible using the [`createVisuallyHidden`](../visually-hidden/) primitive. It is still in the DOM and accessible to assistive technology, but invisible. This example uses SVG to build the visual checkbox, which is hidden from screen readers with aria-hidden.\n\nFor keyboard accessibility, a focus ring is important to indicate which element has keyboard focus. This is implemented with the `createFocusRing` primitive. When `isFocusVisible` is true, an extra SVG element is rendered to indicate focus. The focus ring is only visible when the user is interacting with a keyboard, not with a mouse or touch.\n\n```tsx\nimport { AriaCheckboxProps, createCheckbox } from \"@solid-aria/checkbox\";\nimport { createFocusRing } from \"@solid-aria/focus\";\nimport { createVisuallyHidden } from \"@solid-aria/visually-hidden\";\n\nimport { Show } from \"solid-js/web\";\n\nfunction Checkbox(props: AriaCheckboxProps) {\n  let ref: HTMLInputElement | undefined;\n\n  const { inputProps, state } = createCheckbox(props, () => ref);\n  const { isFocusVisible, focusProps } = createFocusRing();\n  const { visuallyHiddenProps } = createVisuallyHidden();\n\n  return (\n    <label style={{ display: \"flex\", \"align-items\": \"center\" }}>\n      <div {...visuallyHiddenProps}>\n        <input {...inputProps} {...focusProps} ref={ref} />\n      </div>\n      <svg width={24} height={24} aria-hidden=\"true\" style={{ \"margin-right\": \"4px\" }}>\n        <rect\n          x={state.isSelected() ? 4 : 5}\n          y={state.isSelected() ? 4 : 5}\n          width={state.isSelected() ? 16 : 14}\n          height={state.isSelected() ? 16 : 14}\n          fill={state.isSelected() ? \"orange\" : \"none\"}\n          stroke={state.isSelected() ? \"none\" : \"gray\"}\n          stroke-width={2}\n        />\n        <Show when={state.isSelected()}>\n          <path\n            transform=\"translate(7 7)\"\n            d={`M3.788 9A.999.999 0 0 1 3 8.615l-2.288-3a1 1 0 1 1\n            1.576-1.23l1.5 1.991 3.924-4.991a1 1 0 1 1 1.576 1.23l-4.712\n            6A.999.999 0 0 1 3.788 9z`}\n          />\n        </Show>\n        <Show when={isFocusVisible()}>\n          <rect x={1} y={1} width={22} height={22} fill=\"none\" stroke=\"orange\" stroke-width={2} />\n        </Show>\n      </svg>\n      {props.children}\n    </label>\n  );\n}\n\nfunction App() {\n  return <Checkbox>Checkbox</Checkbox>;\n}\n```\n\n### Internationalization\n\n#### RTL\n\nIn right-to-left languages, the checkbox should be mirrored. Ensure that your CSS accounts for this.\n\n# Checkbox Group\n\nCheckbox groups allow users to select multiple items from a list of options.\n\n## `createCheckboxGroup` and `createCheckboxGroupItem`\n\nProvides the behavior and accessibility implementation for a checkbox group component.\n\n### Features\n\nCheckbox groups can be built in HTML with the `<fieldset>` and `<input>` elements, however these can be difficult to style. `createCheckboxGroup` and `createCheckboxGroupItem` help achieve accessible checkbox groups that can be styled as needed.\n\n- Checkbox groups are exposed to assistive technology via ARIA\n- Each checkbox is built with a native HTML `<input>` element, which can be optionally visually hidden to allow custom styling\n- Full support for browser features like form autofill\n- Keyboard focus management and cross browser normalization\n- Group and checkbox labeling support for assistive technology\n\n### How to use it\n\nThis example uses native input elements for the checkboxes, and SolidJS context to share state from the group to each checkbox. An HTML `<label>` element wraps the native input and the text to provide an implicit label for the checkbox.\n\n```tsx\nimport {\n  AriaCheckboxGroupItemProps,\n  AriaCheckboxGroupProps,\n  createCheckboxGroup,\n  createCheckboxGroupItem\n} from \"@solid-aria/checkbox\";\n\nfunction CheckboxGroup(props: AriaCheckboxGroupProps) {\n  const { CheckboxGroupProvider, groupProps, labelProps, state } = createCheckboxGroup(props);\n\n  return (\n    <div {...groupProps}>\n      <span {...labelProps}>{props.label}</span>\n      <CheckboxGroupProvider>{props.children}</CheckboxGroupProvider>\n    </div>\n  );\n}\n\nfunction Checkbox(props: AriaCheckboxGroupItemProps) {\n  let ref: HTMLInputElement | undefined;\n\n  const { inputProps, state } = createCheckboxGroupItem(props, () => ref);\n\n  const isDisabled = () => state.isDisabled() || props.isDisabled;\n  const isSelected = () => state.isSelected(props.value);\n\n  return (\n    <label\n      style={{\n        display: \"block\",\n        color: (isDisabled() && \"gray\") || (isSelected() && \"dodgerblue\")\n      }}\n    >\n      <input {...inputProps} ref={ref} />\n      {props.children}\n    </label>\n  );\n}\n\nfunction App() {\n  return (\n    <CheckboxGroup label=\"Favorite sports\">\n      <Checkbox value=\"soccer\" isDisabled>\n        Soccer\n      </Checkbox>\n      <Checkbox value=\"baseball\">Baseball</Checkbox>\n      <Checkbox value=\"basketball\">Basketball</Checkbox>\n    </CheckboxGroup>\n  );\n}\n```\n\n## Changelog\n\nAll notable changes are described in the [CHANGELOG.md](./CHANGELOG.md) file.\n","gitHead":"53580c26c8f278fd52d4258d2753297c7dd24d92","license":"MIT","private":false,"scripts":{"dev":"vite serve dev --host","test":"jest --passWithNoTests","build":"tsup","clean":"rm -rf .turbo && rm -rf node_modules && rm -rf dist","typecheck":"tsc --noEmit","test:watch":"jest --watch --passWithNoTests"},"_npmUser":{"name":"fabienml","email":"fabienml.dev@gmail.com"},"homepage":"https://github.com/solidjs-community/solid-aria/tree/main/packages/checkbox#readme","keywords":["solid","aria","headless","design","system","components"],"primitive":{"list":[],"name":"checkbox","stage":0,"category":""},"repository":{"url":"git+https://github.com/solidjs-community/solid-aria.git","type":"git"},"_npmVersion":"8.11.0","description":"Primitives for building accessible checkbox and checkbox group component.","directories":{},"maintainers":[{"name":"fabienml","email":"fabienml.dev@gmail.com"},{"name":"davedbase","email":"dave.dibiase@gmail.com"}],"sideEffects":false,"_nodeVersion":"16.15.1","contributors":[],"dependencies":{"@solid-aria/label":"^0.0.0-snapshot-20220617074250","@solid-aria/types":"^0.0.0-snapshot-20220617074250","@solid-aria/utils":"^0.0.0-snapshot-20220617074250","@solid-aria/toggle":"^0.0.0-snapshot-20220617074250","@solid-primitives/props":"^2.1.7","@solid-primitives/utils":"^2.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"solid-js":"^1.4.4"},"peerDependencies":{"solid-js":"^1.4.4"},"_npmOperationalInternal":{"tmp":"tmp/checkbox_0.0.0-snapshot-20220617074250_1655452091955_0.3417554964734504","host":"s3://npm-registry-packages"},"_id":"@solid-aria/checkbox@0.0.0-snapshot-20220617074250","version":"0.0.0-snapshot-20220617074250"}