checkbox.stories.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // @ts-nocheck
  2. import { Icon } from "./icon"
  3. import * as mod from "./checkbox"
  4. import { create } from "../storybook/scaffold"
  5. const docs = `### Overview
  6. Checkbox control for multi-select or agreement inputs.
  7. Use in forms and multi-select lists.
  8. ### API
  9. - Uses Kobalte Checkbox props (\`checked\`, \`defaultChecked\`, \`onChange\`).
  10. - Optional: \`hideLabel\`, \`description\`, \`icon\`.
  11. - Children render as the label.
  12. ### Variants and states
  13. - Checked/unchecked, indeterminate, disabled (via Kobalte).
  14. ### Behavior
  15. - Controlled or uncontrolled usage.
  16. ### Accessibility
  17. - TODO: confirm aria attributes from Kobalte.
  18. ### Theming/tokens
  19. - Uses \`data-component="checkbox"\` and related slots.
  20. `
  21. const story = create({ title: "UI/Checkbox", mod, args: { children: "Checkbox", defaultChecked: true } })
  22. export default {
  23. title: "UI/Checkbox",
  24. id: "components-checkbox",
  25. component: story.meta.component,
  26. tags: ["autodocs"],
  27. parameters: {
  28. docs: {
  29. description: {
  30. component: docs,
  31. },
  32. },
  33. },
  34. }
  35. export const Basic = story.Basic
  36. export const States = {
  37. render: () => (
  38. <div style={{ display: "grid", gap: "12px" }}>
  39. <mod.Checkbox defaultChecked>Checked</mod.Checkbox>
  40. <mod.Checkbox>Unchecked</mod.Checkbox>
  41. <mod.Checkbox disabled>Disabled</mod.Checkbox>
  42. <mod.Checkbox description="Helper text">With description</mod.Checkbox>
  43. </div>
  44. ),
  45. }
  46. export const CustomIcon = {
  47. render: () => (
  48. <mod.Checkbox icon={<Icon name="check" size="small" />} defaultChecked>
  49. Custom icon
  50. </mod.Checkbox>
  51. ),
  52. }
  53. export const HiddenLabel = {
  54. args: {
  55. children: "Hidden label",
  56. hideLabel: true,
  57. },
  58. }