Bộ tăng giảm số
Dùng cho số nhỏ chỉ cần nhấn một hai lần — số lượng, số khách, số đêm, tăng giảm từng đơn vị.
Xem trước trực tiếp
Nguồn
<div class="dc-stp">
<label class="dc-stp__label" for="dc-stp-qty">수량</label>
<div class="dc-stp__group">
<button class="dc-stp__btn" type="button"><span class="dc-sr">한 개 줄이기</span><span aria-hidden="true">−</span></button>
<input class="dc-stp__input" id="dc-stp-qty" type="number" name="qty" inputmode="numeric" value="2" min="1" max="99" step="1" aria-describedby="dc-stp-qty-help">
<button class="dc-stp__btn" type="button"><span class="dc-sr">한 개 늘리기</span><span aria-hidden="true">+</span></button>
</div>
<p class="dc-stp__help" id="dc-stp-qty-help">한 번에 99개까지 담을 수 있습니다.</p>
</div>
.dc-stp {
display: flex; flex-direction: column; gap: var(--dc-2);
font-family: var(--dc-font);
}
.dc-stp__label { font-size: 14px; font-weight: 600; color: var(--dc-text); }
.dc-stp__group {
display: inline-flex; align-items: stretch; align-self: flex-start;
border: 1px solid var(--dc-line-field); border-radius: var(--dc-r-sm);
background: var(--dc-surface); overflow: hidden;
}
.dc-stp__group:focus-within {
border-color: var(--dc-brand); box-shadow: 0 0 0 3px var(--dc-brand-soft);
}
.dc-stp__btn {
flex: none; display: inline-flex; align-items: center; justify-content: center;
width: 44px; min-height: 44px;
border: 0; background: var(--dc-surface); color: var(--dc-text);
font-family: inherit; font-size: 20px; font-weight: 600; line-height: 1;
transition: background var(--dc-fast);
}
.dc-stp__btn:hover { background: var(--dc-sunken); }
.dc-stp__btn:disabled { background: var(--dc-sunken); color: var(--dc-text-mute); cursor: not-allowed; }
.dc-stp__input {
width: 56px; min-height: 44px; padding: 0 var(--dc-1);
border: 0; border-left: 1px solid var(--dc-line); border-right: 1px solid var(--dc-line);
background: var(--dc-surface); color: var(--dc-text);
font-family: var(--dc-mono); font-size: 16px; text-align: center;
font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.dc-stp__input:focus { outline: none; }
.dc-stp__input::-webkit-outer-spin-button,
.dc-stp__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dc-stp__input[disabled] { background: var(--dc-sunken); color: var(--dc-text-mute); cursor: not-allowed; }
.dc-stp__unit {
display: inline-flex; align-items: center; padding: 0 var(--dc-3);
border-right: 1px solid var(--dc-line);
background: var(--dc-sunken); color: var(--dc-text-sub);
font-size: 14px; white-space: nowrap;
}
.dc-stp__help { margin: 0; font-size: 13px; line-height: 1.5; color: var(--dc-text-sub); }
Cách dùng
- Vẫn cho phép gõ trực tiếp — không ai nên bấm ba mươi lần để đặt ba mươi món
- Vô hiệu nút khi đã ở mức nhỏ nhất hoặc lớn nhất, để giới hạn nhìn thấy được chứ không chỉ bị chặn
- Số trên khoảng một trăm, hoặc số tự do, nên dùng ô nhập số thường
Điểm cần lưu ý
- Mỗi nút tối thiểu 44×44px — nhỏ hơn là bấm lẫn sang nút bên cạnh
- Đặt tên cho nút chỉ có biểu tượng; dấu "+" trơ trọi chỉ được đọc là "dấu cộng"