Component Blueprints
Counter
- HTML/CSS:Dev Ready
- Layout:Responsive
Sections
The Counter allows a user to increase or decrease a numerical value.
About Counter#
A Counter is a Form Element containing a label and a number Input that can be increased or decreased using companion Button Icons.
Accessibility#
To ensure the Counter is fully accessible, follow all guidelines for Button Icons and the error state on Inputs.
Base#
<div class="slds-form-element">
<label class="slds-form-element__label slds-m-right_none" for="default1">Counter Label</label>
<div class="slds-form-element__control">
<button class="slds-button slds-button_icon slds-button_icon-small slds-input__button_decrement" title="Decrement counter">
States#
Required#
<div class="slds-form-element">
<label class="slds-form-element__label slds-m-right_none" for="state-required">
<abbr class="slds-required" title="required">* </abbr>Counter Label</label>
<div class="slds-form-element__control">
Error#
This field is required
<div class="slds-form-element slds-has-error">
<label class="slds-form-element__label slds-m-right_none" for="state-error">
<abbr class="slds-required" title="required">* </abbr>Counter Label</label>
<div class="slds-form-element__control">
Disabled#
<div class="slds-form-element">
<label class="slds-form-element__label slds-m-right_none" for="state-disabled">Counter Label</label>
<div class="slds-form-element__control">
<button class="slds-button slds-button_icon slds-button_icon-small slds-input__button_decrement" title="Decrement counter" disabled="">
Read-only#
<div class="slds-form-element">
<label class="slds-form-element__label slds-m-right_none" for="state-read-only">Counter Label</label>
<div class="slds-form-element__control">
<input type="text" id="state-read-only" placeholder="1" readonly="" class="slds-input" />
Examples#
Centered#
<div class="slds-form-element slds-text-align_center">
<label class="slds-form-element__label slds-m-right_none" for="example-centered">Counter Label</label>
<div class="slds-form-element__control">
<button class="slds-button slds-button_icon slds-button_icon-small slds-input__button_decrement" title="Decrement counter">
Overview of CSS Classes#
- Selector
- The CSS class being referred to.
- Summary
- A description of what the class does.
- Support
- Whether the class name is dev-ready (meaning it's fully vetted and tested and safe to use) or prototype (which means it's not fully vetted yet).
- Restrict
- The selector that the class name is allowed to be used on.
- Variant
- The base level pattern for a component. A variant can be extended to create another variant of that component, for example, a stateful button is a derivative of the base button.
- Modifier
- A single class that can be added to an HTML element of a component to modify its output. Typically these will be colors, sizing and positioning.
Selector | .slds-input_counter |
---|---|
Summary | Variant for number input with increment and decrement buttons |
Restrict | .slds-input |
Variant | True |
Counter Release Notes
2.10.0
- Created new page for the Counter version of Input.