Form Indeterminate Checkboxes
src / Demo.tsx
12345678910111213141516171819202122232425262728293031import React, { ReactElement } from "react";
import { Checkbox, Fieldset, useIndeterminateChecked } from "@react-md/form";
const condiments = ["Lettuce", "Tomato", "Mustard", "Sprouts"];
export default function Demo(): ReactElement {
const {
getProps,
rootProps,
} = useIndeterminateChecked(condiments, ["Sprouts"]);
return (
<Fieldset legend="Sandwich Condiments" unstyled={false}>
<Checkbox id="condiments-all" label="All Condiments" {...rootProps} />
<ul role="none" style={{ listStyleType: "none" }}>
{condiments.map((condiment, i) => (
<li key={condiment}>
<Checkbox
id={`condiment-${i}`}
label={condiment}
name="condiment"
{...getProps(condiment)}
/>
</li>
))}
</ul>
</Fieldset>
);
}