segmented-controls-react
Version:
A good-lookin' segmented control React component ๐ฅ
47 lines (44 loc) โข 1.58 kB
TypeScript
import { Dispatch, SetStateAction } from "react";
export interface Props {
options: {
value: string;
disabled?: boolean;
}[];
setValue: Dispatch<SetStateAction<string>>;
size: "large" | "small";
name: string;
defaultIndex: number;
}
/**
*
* @param {{ value: string, disabled?: boolean }[]} props.options ์ธ๊ทธ๋จผํธ์ ์ต์
์ value์ ๋ด์์ฃผ์ธ์. ๋นํ์ฑํ ํ๊ธธ ์ํ๋ ๋ฒํผ์ disabled ์์ฑ์ ์ ์ฉํด์ฃผ์ธ์.
* @param { Dispatch<SetStateAction<string>> } props.setValue ์ ํ๋ ์ธ๊ทธ๋จผํธ๋ฅผ string์ผ๋ก ๋ฆฌํดํด์
* @param { "large" | "small" } props.size ์ธ๊ทธ๋จผํธ์ ํฌ๊ธฐ๋ฅผ ์ ํด์ฃผ์ธ์. large ํน์ small์ ๊ฐ์ ๊ฐ์ ธ์.
* @param { string } props.name input์ name๊ฐ์ ๋ฃ์ด์ฃผ์ธ์. ์น ์ ๊ทผ์ฑ์ ์ํจ์ด์์.
* @param { defaultIndex } props.number ์ฒ์ ์ ํ๋์ด์๊ธธ ์ํ๋ ๊ฐ์ ๋ฃ์ด์ฃผ์ธ์.
* @example
* ```jsx
import React from "react";
import { SegmentedControls } from "segmented-controls-react";
const App = () => {
return (
<>
<SegmentedControls
options={[
{ value: "one", disabled: true },
{ value: "two" },
{ value: "three" },
]}
defaultIndex={1}
setValue={(val) => console.log(val)}
size={"large"}
name={"one"}
/>
</>
);
};
export default App;
* ```
*/
declare const SegmentedControls: ({ options, setValue, size, name, defaultIndex, }: Props) => JSX.Element;
export default SegmentedControls;