Clawscale

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
PropsDescription
alignIndicator
Alignment = Alignment.START
Alignment of the indicator within container.
Inherited from ControlProps
checked
boolean
Whether the control is checked.
Inherited from CheckedControlProps
className
string
A space-delimited list of class names to pass along to a child element.
Inherited from Props
compact
boolean = false
Whether this component should use compact styles with reduced visual padding.
Inherited from CardProps
disabled
boolean
Whether the control is non-interactive.
Inherited from ControlProps
elevation
Elevation = 0
Controls the intensity of the drop shadow beneath the card: the higher the elevation, the higher the drop shadow. At elevation 0, no drop shadow is applied.
Inherited from CardProps
inputProps
Omit<HTMLInputProps, "size">
HTML input attributes to forward to the control <input> element.
Inherited from ControlCardProps
inputRef
React.Ref<HTMLInputElement>
Ref attached to the HTML <input> element backing this component.
Inherited from ControlProps
label
string
Text 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>) => void
Callback invoked when the card is clicked. Recommended when interactive is true.
Inherited from CardProps
selected
boolean = undefined
Whether this card should appear selected.
Inherited from CardProps
showAsSelectedWhenChecked
boolean = true
Whether the component should use "selected" Card styling when checked.
Inherited from ControlCardProps
type CheckboxCardProps@clawscale/react
PropsDescription
alignIndicator
Alignment = Alignment.START
Alignment of the indicator within container.
Inherited from ControlProps
checked
boolean
Whether the control is checked.
Inherited from CheckedControlProps
className
string
A space-delimited list of class names to pass along to a child element.
Inherited from Props
compact
boolean = false
Whether this component should use compact styles with reduced visual padding.
Inherited from CardProps
disabled
boolean
Whether the control is non-interactive.
Inherited from ControlProps
elevation
Elevation = 0
Controls the intensity of the drop shadow beneath the card: the higher the elevation, the higher the drop shadow. At elevation 0, no drop shadow is applied.
Inherited from CardProps
inputProps
Omit<HTMLInputProps, "size">
HTML input attributes to forward to the control <input> element.
Inherited from ControlCardProps
inputRef
React.Ref<HTMLInputElement>
Ref attached to the HTML <input> element backing this component.
Inherited from ControlProps
label
string
Text 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>) => void
Callback invoked when the card is clicked. Recommended when interactive is true.
Inherited from CardProps
selected
boolean = undefined
Whether this card should appear selected.
Inherited from CardProps
showAsSelectedWhenChecked
boolean = true
Whether the component should use "selected" Card styling when checked.
Inherited from ControlCardProps
type RadioCardProps@clawscale/react
PropsDescription
alignIndicator
Alignment = Alignment.START
Alignment of the indicator within container.
Inherited from ControlProps
checked
boolean
Whether the control is checked.
Inherited from CheckedControlProps
className
string
A space-delimited list of class names to pass along to a child element.
Inherited from Props
compact
boolean = false
Whether this component should use compact styles with reduced visual padding.
Inherited from CardProps
disabled
boolean
Whether the control is non-interactive.
Inherited from ControlProps
elevation
Elevation = 0
Controls the intensity of the drop shadow beneath the card: the higher the elevation, the higher the drop shadow. At elevation 0, no drop shadow is applied.
Inherited from CardProps
inputProps
Omit<HTMLInputProps, "size">
HTML input attributes to forward to the control <input> element.
Inherited from ControlCardProps
inputRef
React.Ref<HTMLInputElement>
Ref attached to the HTML <input> element backing this component.
Inherited from ControlProps
label
string
Text 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>) => void
Callback invoked when the card is clicked. Recommended when interactive is true.
Inherited from CardProps
selected
boolean = undefined
Whether this card should appear selected.
Inherited from CardProps
showAsSelectedWhenChecked
boolean = true
Whether the component should use "selected" Card styling when checked.
Inherited from ControlCardProps