Develop ultra fast with Prismane 🎉

SegmentedField

SegmentedField displays a field that handles toggling between multiple values.

Import

import { SegmentedField } from "@prismane/core";

Usage

function Demo() {
  const [value, setValue] = useState("star");

  const handleChange = (e) => setValue(e.target.value);

  return (
    <SegmentedField
      value={value}
      onChange={handleChange}
      options={[
        { element: "Star", value: "star" },
        { element: "Circle", value: "circle" },
        { element: "Square", value: "square" },
      ]}
    />
  );
}

SegmentedField Sizes

function Demo() {
  const [value, setValue] = useState("star");

  return (
    <Flex direction="column" gap={fr(2)}>
      <SegmentedField
        size="xs"
        placeholder="Default Field"
        label="Default Field:"
        value={value}
        onChange={(e) => setValue(e.target.value)}
        options={[
          { element: "Star", value: "star" },
          { element: "Circle", value: "circle" },
          { element: "Square", value: "square" },
        ]}
      />
      <SegmentedField
        size="sm"
        placeholder="Default Field"
        label="Default Field:"
        value={value}
        onChange={(e) => setValue(e.target.value)}
        options={[
          { element: "Star", value: "star" },
          { element: "Circle", value: "circle" },
          { element: "Square", value: "square" },
        ]}
      />
      <SegmentedField
        size="base"
        placeholder="Default Field"
        label="Default Field:"
        value={value}
        onChange={(e) => setValue(e.target.value)}
        options={[
          { element: "Star", value: "star" },
          { element: "Circle", value: "circle" },
          { element: "Square", value: "square" },
        ]}
      />
      <SegmentedField
        size="md"
        placeholder="Default Field"
        label="Default Field:"
        value={value}
        onChange={(e) => setValue(e.target.value)}
        options={[
          { element: "Star", value: "star" },
          { element: "Circle", value: "circle" },
          { element: "Square", value: "square" },
        ]}
      />
      <SegmentedField
        size="lg"
        placeholder="Default Field"
        label="Default Field:"
        value={value}
        onChange={(e) => setValue(e.target.value)}
        options={[
          { element: "Star", value: "star" },
          { element: "Circle", value: "circle" },
          { element: "Square", value: "square" },
        ]}
      />
    </Flex>
  );
}

API

Please refer to the documentation below for a comprehensive overview of all the available props and classes for the mentioned components.