1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-12-27 00:31:35 +01:00
foris-js/src/bootstrap/RadioSet.md

28 lines
733 B
Markdown
Raw Normal View History

2020-08-18 15:39:00 +02:00
Set of radio Bootstrap component input with label and predefined sizes and
structure for using in foris forms.
2019-08-23 15:20:22 +02:00
All additional `props` are passed to the `<input type="number">` HTML component.
2019-10-24 10:12:39 +02:00
Unless `helpText` is set for one of the options they are displayed inline.
2019-08-23 15:20:22 +02:00
```js
2020-08-18 15:39:00 +02:00
import { useState } from "react";
const CHOICES = [
{ value: "one", label: "1" },
{ value: "two", label: "2" },
{ value: "three", label: "3" },
2019-08-23 15:20:22 +02:00
];
const [value, setValue] = useState(CHOICES[0].value);
<>
{/*Yeah, it gets event, not value!*/}
<RadioSet
value={value}
2020-08-18 15:39:00 +02:00
name="some-radio"
2019-08-23 15:20:22 +02:00
choices={CHOICES}
2020-08-18 15:39:00 +02:00
onChange={(event) => setValue(event.target.value)}
2019-08-23 15:20:22 +02:00
/>
<p>Selected value: {value}</p>
2020-08-18 15:39:00 +02:00
</>;
2019-08-23 15:20:22 +02:00
```