segmented-controls-react
TypeScript icon, indicating that this package has built-in type declarations

1.0.22 โ€ข Public โ€ข Published

์‹คํ–‰ ํ™˜๊ฒฝ

๋ถˆํ•„์š”ํ•œ ๋…ธ๋“œ๋ฅผ ์ตœ์†Œํ™” ํ•˜๊ธฐ ์œ„ํ•ด webpack์œผ๋กœ React + Typescript + Styled Components + Storybook์„ ์„ธํŒ…ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ฐ„๋‹จํ•œ lint, prettier ์„ค์ •๋„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

label๊ณผ input์„ ์—ฐ๊ฒฐํ•ด ์›น ์ ‘๊ทผ์„ฑ์„ ๊ณ ๋ คํ•œ ๊ฐœ๋ฐœ์„ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

framer-motion ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๋ชจ๋ฐ”์ผ ํ™˜๊ฒฝ์—์„œ๋„ ๋™์ผํ•œ ์‚ฌ์šฉ๊ฐ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

์‹คํ–‰ ๋ฐฉ๋ฒ•

  1. package install
  • npm i (or yarn)
  1. run dev server
  • npm run dev (or yarn dev)๋ฅผ ํ†ตํ•ด ๊ตฌํ˜„๋œ ์ปดํฌ๋„ŒํŠธ๋ฅผ localhost:3000์—์„œ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  1. build
  • npm run build (or yarn build)

์‚ฌ์šฉ๋ฒ•

const App = () => {
  return (
    <>
      <SegmentedControls
        options={[
          { value: "one", disabled: true },
          { value: "two" },
          { value: "three" },
        ]}
        defaultIndex={1}
        setValue={(val) => console.log(val)}
        size={"large"}
        name={"one"}
      />
      <SegmentedControls
        options={[
          { value: "one", disabled: true },
          { value: "two" },
          { value: "three" },
          { value: "four" },
        ]}
        defaultIndex={1}
        setValue={(val) => console.log(val)}
        size={"small"}
        name={"two"}
      />
    </>
  );
};

๊ฒฐ๊ณผ๋ฌผ

Demo

์†์„ฑ

Name Type Default Description
options { value: string, disabled?: boolean }[] Enter the label of segments
setValue Dispatch<SetStateAction<string>> callback on input change, passed the value string. Called once initially with the default value on mount.
size large or small Enter the size of component you want
name string Enter name of the radio s
defaultIndex number You could set default value through this property

Package Sidebar

Install

npm i segmented-controls-react@1.0.22

Version

1.0.22

License

ISC

Unpacked Size

57.9 kB

Total Files

24

Last publish

Collaborators

  • dusdjeks