Control card
A control card is a Card with a switch, checkbox or radio inside. A click anywhere on the card toggles the control.
Usage#
import { CheckboxCard, RadioCard, SwitchCard } from "@clawscale/react";<SwitchCard defaultChecked>Alert on failed runs</SwitchCard>Examples#
Switch card#
SwitchCard places a Switch at the end of the card. Pass the label as children or as label. A checked card looks selected; set showAsSelectedWhenChecked={false} to turn that off.
import { SwitchCard } from "@clawscale/react";
export default function ControlCardSwitch() {
return (
<>
<SwitchCard defaultChecked style={{ width: 240 }}>
Alert on failed runs
</SwitchCard>
<SwitchCard style={{ width: 240 }}>Alert on slow runs</SwitchCard>
</>
);
}Checkbox card#
CheckboxCard places a Checkbox at the start of the card. alignIndicator moves the control to either side.
import { CheckboxCard } from "@clawscale/react";
export default function ControlCardCheckbox() {
return (
<>
<CheckboxCard defaultChecked label="us-east-1" />
<CheckboxCard defaultChecked label="eu-west-1" />
<CheckboxCard label="ap-southeast-2" />
</>
);
}Radio card#
RadioCard goes inside a RadioGroup, which tracks the selected value.
import { RadioCard, RadioGroup } from "@clawscale/react";
import { useState } from "react";
export default function ControlCardRadio() {
const [size, setSize] = useState("medium");
return (
<RadioGroup
name="warehouse-size"
aria-label="Warehouse size"
selectedValue={size}
onChange={(event) => setSize(event.currentTarget.value)}
style={{ display: "grid", gap: 8, width: 280 }}
>
<RadioCard label="Small: 2 vCPU, 8 GB" value="small" />
<RadioCard label="Medium: 8 vCPU, 32 GB" value="medium" />
<RadioCard label="Large: 32 vCPU, 128 GB" value="large" />
</RadioGroup>
);
}Card list#
Control cards work as rows in a Card list.
import { CardList, SwitchCard } from "@clawscale/react";
export default function ControlCardList() {
return (
<CardList role="group" aria-label="Pipeline options" style={{ maxWidth: 400 }}>
<SwitchCard defaultChecked>Run on schedule</SwitchCard>
<SwitchCard defaultChecked>Retry failed steps</SwitchCard>
<SwitchCard>Notify on success</SwitchCard>
<SwitchCard>Keep intermediate files</SwitchCard>
</CardList>
);
}Props interface#
The three components share one set of props.
type SwitchCardProps@clawscale/react| Props | Description |
|---|---|
alignIndicator | Alignment = Alignment.STARTAlignment of the indicator within container. Inherited from ControlProps |
checked | booleanWhether the control is checked. Inherited from CheckedControlProps |
className | stringA space-delimited list of class names to pass along to a child element. Inherited from Props |
compact | boolean = falseWhether this component should use compact styles with reduced visual padding. Inherited from CardProps |
disabled | booleanWhether the control is non-interactive. Inherited from ControlProps |
elevation | Elevation = 0Controls the intensity of the drop shadow beneath the card: the higher the elevation, the higher the drop shadow. At elevation Inherited from 0, no drop shadow is applied.CardProps |
inputProps | Omit<HTMLInputProps, "size">HTML input attributes to forward to the control Inherited from <input> element.ControlCardProps |
inputRef | React.Ref<HTMLInputElement>Ref attached to the HTML Inherited from <input> element backing this component.ControlProps |
label | stringText label for the control. Inherited from ControlProps |
onChange | React.ChangeEventHandler<HTMLInputElement>Event handler invoked when input value is changed. Inherited from CheckedControlProps |
onClick | (e: React.MouseEvent<HTMLDivElement>) => voidCallback invoked when the card is clicked. Recommended when Inherited from interactive is true.CardProps |
selected | boolean = undefinedWhether this card should appear selected. Inherited from CardProps |
showAsSelectedWhenChecked | boolean = trueWhether the component should use "selected" Card styling when checked. Inherited from ControlCardProps |
type CheckboxCardProps@clawscale/react| Props | Description |
|---|---|
alignIndicator | Alignment = Alignment.STARTAlignment of the indicator within container. Inherited from ControlProps |
checked | booleanWhether the control is checked. Inherited from CheckedControlProps |
className | stringA space-delimited list of class names to pass along to a child element. Inherited from Props |
compact | boolean = falseWhether this component should use compact styles with reduced visual padding. Inherited from CardProps |
disabled | booleanWhether the control is non-interactive. Inherited from ControlProps |
elevation | Elevation = 0Controls the intensity of the drop shadow beneath the card: the higher the elevation, the higher the drop shadow. At elevation Inherited from 0, no drop shadow is applied.CardProps |
inputProps | Omit<HTMLInputProps, "size">HTML input attributes to forward to the control Inherited from <input> element.ControlCardProps |
inputRef | React.Ref<HTMLInputElement>Ref attached to the HTML Inherited from <input> element backing this component.ControlProps |
label | stringText label for the control. Inherited from ControlProps |
onChange | React.ChangeEventHandler<HTMLInputElement>Event handler invoked when input value is changed. Inherited from CheckedControlProps |
onClick | (e: React.MouseEvent<HTMLDivElement>) => voidCallback invoked when the card is clicked. Recommended when Inherited from interactive is true.CardProps |
selected | boolean = undefinedWhether this card should appear selected. Inherited from CardProps |
showAsSelectedWhenChecked | boolean = trueWhether the component should use "selected" Card styling when checked. Inherited from ControlCardProps |
type RadioCardProps@clawscale/react| Props | Description |
|---|---|
alignIndicator | Alignment = Alignment.STARTAlignment of the indicator within container. Inherited from ControlProps |
checked | booleanWhether the control is checked. Inherited from CheckedControlProps |
className | stringA space-delimited list of class names to pass along to a child element. Inherited from Props |
compact | boolean = falseWhether this component should use compact styles with reduced visual padding. Inherited from CardProps |
disabled | booleanWhether the control is non-interactive. Inherited from ControlProps |
elevation | Elevation = 0Controls the intensity of the drop shadow beneath the card: the higher the elevation, the higher the drop shadow. At elevation Inherited from 0, no drop shadow is applied.CardProps |
inputProps | Omit<HTMLInputProps, "size">HTML input attributes to forward to the control Inherited from <input> element.ControlCardProps |
inputRef | React.Ref<HTMLInputElement>Ref attached to the HTML Inherited from <input> element backing this component.ControlProps |
label | stringText label for the control. Inherited from ControlProps |
onChange | React.ChangeEventHandler<HTMLInputElement>Event handler invoked when input value is changed. Inherited from CheckedControlProps |
onClick | (e: React.MouseEvent<HTMLDivElement>) => voidCallback invoked when the card is clicked. Recommended when Inherited from interactive is true.CardProps |
selected | boolean = undefinedWhether this card should appear selected. Inherited from CardProps |
showAsSelectedWhenChecked | boolean = trueWhether the component should use "selected" Card styling when checked. Inherited from ControlCardProps |