@blueprintjs/core
Version:
Core styles & components
80 lines (52 loc) • 2.82 kB
Markdown
---
tag: new
---
@
A control card is an interactive [**Card**](
There are a few supported form controls, each has a corresponding component API:
- [**SwitchCard**](
- [**CheckboxCard**](
- [**RadioCard**](
The label may be specified as either `children` (`React.ReactNode`) or the `label` prop (`string`).
Users may click anywhere inside the card to toggle the control state.
By default, a "checked" control card will be displayed with the same appearance as a "selected" card.
This behavior may be toggled with the `showAsSelectedWhenChecked` prop.
@
Card with an embedded [**Switch**](
Most of the properties in [**CardProps**](
[**SwitchProps**](
@reactExample SwitchCardExample
@
Card with an embedded [**Checkbox**](
Most of the properties in [**CardProps**](
[**CheckboxProps**](
@reactExample CheckboxCardExample
@
Card with an embedded [**Radio**](
Most of the properties in [**CardProps**](
[**RadioProps**](
Just like the **Radio** component, a **RadioCard** is usually contained in a
[**RadioCardGroup**](
```tsx
import { RadioGroup, RadioCard } from "@blueprintjs/core";
import React from "react";
function RadioCardGroupExample() {
const [selectedValue, setSelectedValue] = React.useState<string | undefined>();
const handleChange = React.useCallback((event: React.FormEvent<HTMLInputElement>) => {
setSelectedValue(event.currentTarget.value);
}, []);
return (
<RadioGroup selectedValue={selectedValue} onChange={handleChange} label="Lunch Special">
<RadioCard label="Soup" value="soup" />
<RadioCard label="Salad" value="salad" />
<RadioCard label="Sandwich" value="sandwich" />
</RadioGroup>
);
}
```
@reactExample RadioCardGroupExample
@
@interface ControlCardProps
@
Control cards work just like regular cards inside a [**CardList**](
@reactExample ControlCardListExample