Anonymous View
14.3.5 • Published 2 years ago

@rmwc/segmented-button v14.3.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Segmented Button

Segmented buttons allow users to toggle the selected states of grouped buttons.

function Example() {
  const [selected, setSelected] = React.useState({
    cookies: false,
    pizza: false,
    icecream: false
  });
  const toggleSelected = (key) =>
    setSelected({ ...selected, [key]: !selected[key] });
  return (
    <SegmentedButton>
      <Segment
        icon="favorite"
        value="cookies"
        onClick={() => toggleSelected('cookies')}
        selected={selected.cookies}
      />
      <Segment
        label="Button"
        value="pizza"
        onClick={() => toggleSelected('pizza')}
        selected={selected.pizza}
      />
      <Segment
        icon="favorite"
        label="Button"
        value="icecream"
        onClick={() => toggleSelected('icecream')}
        selected={selected.icecream}
      />
    </SegmentedButton>
  );
}
function Example() {
  const [selected, setSelected] = React.useState('icecream');
  return (
    <SegmentedButton selectType="single">
      <Segment
        icon="favorite"
        value="cookies"
        onClick={(evt) => setSelected(evt.currentTarget.value)}
        selected={selected === 'cookies'}
      />
      <Segment
        label="Button"
        value="pizza"
        onClick={(evt) => setSelected(evt.currentTarget.value)}
        selected={selected === 'pizza'}
      />
      <Segment
        icon="favorite"
        label="Button"
        value="icecream"
        onClick={(evt) => setSelected(evt.currentTarget.value)}
        selected={selected === 'icecream'}
      />
    </SegmentedButton>
  );
}
<>
  {/** Wrapping a button in TouchTargetWrapper will automatically set its `touch` prop to true. */}
  <TouchTargetWrapper>
    <Segment>Touch Accessible</Segment>
  </TouchTargetWrapper>
</>

SegmentedButton

Props

NameTypeDescription
selectType"multiple" \| "single"Determines whether the user is able to select multiple or a single button at a time. Default to multiple.
14.3.5

2 years ago

14.3.4

2 years ago

14.3.3

2 years ago

14.2.7

2 years ago

14.2.8

2 years ago

14.2.9

2 years ago

14.3.0

2 years ago

14.3.1

2 years ago

14.3.2

2 years ago

14.2.5

2 years ago

14.2.6

2 years ago

14.2.2

2 years ago

14.2.0

2 years ago

14.2.1

2 years ago

14.1.5

2 years ago

14.1.4

2 years ago

14.1.3

2 years ago

14.1.2

2 years ago

14.1.1

2 years ago

14.1.0

2 years ago

14.0.12

2 years ago

14.0.11

2 years ago

14.0.10

2 years ago

14.0.9

2 years ago

14.0.8

2 years ago

14.0.7

2 years ago

14.0.6

2 years ago

14.0.5

2 years ago

14.0.4

3 years ago

14.0.3

3 years ago

14.0.2

3 years ago

14.0.1

3 years ago

14.0.0

3 years ago

14.0.2-alpha.7

3 years ago

14.0.2-alpha.6

3 years ago

14.0.2-alpha.5

3 years ago

14.0.2-alpha.4

3 years ago

14.0.2-alpha.3

3 years ago

14.0.2-alpha.1

3 years ago

14.0.2-alpha.0

3 years ago

14.0.1-alpha.0

3 years ago

14.0.0-alpha.0

3 years ago