ChoiceGroup

link - developer.microsoft.com/en-us/fluentui#/controls/web/choicegroup
This control allows the user to select a single option from two or more choices.

import * as React from 'react';  
import { ChoiceGroup, IChoiceGroupOption } from '@fluentui/react';

export interface IChoiceGroupBasicExampleState {
  imageKey: string;
}

export class ChoiceGroupBasicExample extends React.Component<any, IChoiceGroupBasicExampleState> {
  constructor() {
    super();

    this.state = {
      imageKey: ''
    };
  }

  render() {
    return (
      <div>
        <ChoiceGroup
          defaultSelectedKey='B'
          options={ [
            {
              key: 'A',
              text: 'Option B',
            },
            {
              key: 'B',
              text: 'Option B',
            },
            {
              key: 'C',
              text: 'Option C',
            },
            {
              key: 'D',
             text: 'Option D',
              disabled: true
            }
          ] }
          onChange={ this._onChange }
          label='Pick one'
          required={ true }
        />
      </div>
    );
  }

  _onChange(ev: React.FormEvent<HTMLInputElement>, option: any) {
    console.dir(option);
  }
}


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext