Stepper
Stepper 컴포넌트는 사용자가 여러 단계로 이루어진 과정을 차례대로 진행하도록 안내합니다.
예제
Default
Compound component with editable input. Use StepperContainer to wrap the buttons and input, and compose with StepperDecreaseButton, StepperInput, and StepperIncreaseButton.
1import {
2 Stepper,
3 StepperContainer,
4 StepperDecreaseButton,
5 StepperIncreaseButton,
6 StepperInput,
7} from '@devup-ui/components'
8
9export default function Default() {
10 return (
11 <Stepper>
12 <StepperContainer>
13 <StepperDecreaseButton />
14 <StepperInput />
15 <StepperIncreaseButton />
16 </StepperContainer>
17 </Stepper>
18 )
19}
201import {
2 Stepper,
3 StepperContainer,
4 StepperDecreaseButton,
5 StepperIncreaseButton,
6 StepperInput,
7} from '@devup-ui/components'
8
9export default function Default() {
10 return (
11 <Stepper>
12 <StepperContainer>
13 <StepperDecreaseButton />
14 <StepperInput />
15 <StepperIncreaseButton />
16 </StepperContainer>
17 </Stepper>
18 )
19}
20Type
Use type="text" to display the value as read-only text instead of an editable input. Users can only change the value using the increase/decrease buttons.
1import {
2 Stepper,
3 StepperContainer,
4 StepperDecreaseButton,
5 StepperIncreaseButton,
6 StepperInput,
7} from '@devup-ui/components'
8
9export default function TextType() {
10 return (
11 <Stepper defaultValue={5} type="text">
12 <StepperContainer>
13 <StepperDecreaseButton />
14 <StepperInput />
15 <StepperIncreaseButton />
16 </StepperContainer>
17 </Stepper>
18 )
19}
201import {
2 Stepper,
3 StepperContainer,
4 StepperDecreaseButton,
5 StepperIncreaseButton,
6 StepperInput,
7} from '@devup-ui/components'
8
9export default function TextType() {
10 return (
11 <Stepper defaultValue={5} type="text">
12 <StepperContainer>
13 <StepperDecreaseButton />
14 <StepperInput />
15 <StepperIncreaseButton />
16 </StepperContainer>
17 </Stepper>
18 )
19}
20Min & Max
Use min and max props to limit the value range. The decrease button is disabled at min value, and the increase button is disabled at max value.
1import {
2 Stepper,
3 StepperContainer,
4 StepperDecreaseButton,
5 StepperIncreaseButton,
6 StepperInput,
7} from '@devup-ui/components'
8
9export default function MinMax() {
10 return (
11 <Stepper defaultValue={5} max={10} min={0}>
12 <StepperContainer>
13 <StepperDecreaseButton />
14 <StepperInput />
15 <StepperIncreaseButton />
16 </StepperContainer>
17 </Stepper>
18 )
19}
201import {
2 Stepper,
3 StepperContainer,
4 StepperDecreaseButton,
5 StepperIncreaseButton,
6 StepperInput,
7} from '@devup-ui/components'
8
9export default function MinMax() {
10 return (
11 <Stepper defaultValue={5} max={10} min={0}>
12 <StepperContainer>
13 <StepperDecreaseButton />
14 <StepperInput />
15 <StepperIncreaseButton />
16 </StepperContainer>
17 </Stepper>
18 )
19}
20API
Stepper 컴포넌트는 여러 부분으로 구성된 컴파운드 컴포넌트입니다.
Stepper
stepper에 컨텍스트를 제공하는 루트 컴포넌트입니다.
| 속성 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| children | stepper의 내용(Container, Buttons, Input) |
|
|
| value | stepper의 제어 값 |
|
|
| defaultValue | stepper의 기본값(비제어) |
|
|
| onValueChange | stepper 값이 바뀔 때 호출되는 콜백 |
|
|
| min | 허용되는 최솟값 |
|
|
| max | 허용되는 최댓값 |
|
|
| type | 값을 input으로 편집할 수 있게 할지, 텍스트로 표시할지 여부 |
|
|
StepperContainer
stepper 요소를 감싸는 flex 컨테이너입니다.
StepperDecreaseButton
stepper 값을 1 줄이는 버튼입니다. 값이 min에 도달하면 자동으로 비활성화됩니다.
StepperIncreaseButton
stepper 값을 1 늘리는 버튼입니다. 값이 max에 도달하면 자동으로 비활성화됩니다.
StepperInput
현재 값을 표시합니다. type이 'input'이면 사용자가 값을 직접 편집할 수 있습니다.