Co-authored-by: daKmoR <Thomas.Allmer@ing.com> Co-authored-by: CubLion <Alex.Ghiu@ing.com>
46 lines
1.5 KiB
Text
46 lines
1.5 KiB
Text
import { Story, Meta, html } from '@open-wc/demoing-storybook';
|
|
|
|
import '../lion-radio.js';
|
|
|
|
<Meta title="Forms/Radio" parameters={{ component: 'lion-radio' }} />
|
|
|
|
# Radio
|
|
|
|
`lion-radio` component is a sub-element to be used in [lion-radio-group](?path=/docs/forms-radio-group--default-story) elements. Its purpose is to provide a way for users to check a **single** option amongst a set of choices.
|
|
|
|
<Story name="Default">{html`
|
|
<lion-radio-group name="dinos">
|
|
<lion-radio label="allosaurus" .choiceValue=${'allosaurus'}></lion-radio>
|
|
<lion-radio label="brontosaurus" .choiceValue=${'brontosaurus'}></lion-radio>
|
|
<lion-radio label="diplodocus" .choiceValue=${'diplodocus'} checked></lion-radio>
|
|
</lion-radio-group>
|
|
`}</Story>
|
|
|
|
```html
|
|
<lion-radio-group name="dinos">
|
|
<lion-radio label="allosaurus" .choiceValue=${'allosaurus'}></lion-radio>
|
|
<lion-radio label="brontosaurus" .choiceValue=${'brontosaurus'}></lion-radio>
|
|
<lion-radio label="diplodocus" .choiceValue=${'diplodocus'} checked></lion-radio>
|
|
</lion-radio-group>
|
|
```
|
|
|
|
- Use this component inside a [lion-radio-group](?path=/docs/forms-radio-group--default-story)
|
|
- Make sure that it has a name attribute with appended `[]` for multiple choices.
|
|
|
|
## Features
|
|
|
|
- Get the checked state (boolean) - `checked` boolean attribute
|
|
- Pre-select an option by setting the `checked` boolean attribute
|
|
- Get or set the value of the choice - `choiceValue()`
|
|
|
|
## How to use
|
|
|
|
### Installation
|
|
|
|
```sh
|
|
npm i --save @lion/radio
|
|
```
|
|
|
|
```js
|
|
import '@lion/radio/lion-radio.js';
|
|
```
|