@@ -56,13 +56,121 @@ Use in your components
5656| step | ` number ` | ` 1 ` | Transition time for the animation |
5757| minusTemplate | ` TemplateRef ` | ` - ` | Pass a TemplateRef to replace the minus button content |
5858| plusTemplate | ` TemplateRef ` | ` + ` | Pass a TemplateRef to replace the plus button content |
59+ | minusClass | ` string ` | ` 'ngx-input-counter-button' ` | Classes of the minus button |
60+ | plusClass | ` string ` | ` 'ngx-input-counter-button' ` | Classes of the plus button |
61+ | valueClass | ` string ` | ` 'ngx-input-counter-value' ` | Classes of value text |
62+ | disabled | ` boolean ` | ` false ` | Disables the buttons
5963
6064### Outputs
6165
6266| Name | Payload | Description |
6367| --- | ------ | ------- |
6468| change | value | Triggered when state of the component changes. <br >Contains: <br >` value ` - state of the component |
6569
70+ ## Styling
71+
72+ You can use the default classes and add your own styles or using a custom class:
73+
74+ The classes in the component are:
75+
76+ - ` ngx-input-counter-container ` : The container element.
77+ - ` ngx-input-counter-button ` : The buttons element.
78+ - ` ngx-input-counter-value ` : The value element .
79+
80+ ``` scss
81+ ngx-input-counter .custom {
82+ .ngx-input-counter-container {
83+ border-radius : 50px ;
84+ text-align : center ;
85+ .ngx-input-counter-value {
86+ width : 30px ;
87+ font-weight : bold ;
88+ font-size : 18px ;
89+ }
90+ }
91+ .ngx-input-counter-button {
92+ border : 1px solid #999 ;
93+ border-radius : 100% ;
94+ background-color : white ;
95+ width : 36px ;
96+ height : 36px ;
97+ text-align : center ;
98+ font-weight : 600 ;
99+ font-size : 20px ;
100+ cursor : pointer ;
101+ transition : all 0.5s ease ;
102+ & :hover {
103+ background-color : #ddd ;
104+ box-shadow : 1px 1px 2px 1px #ccc ;
105+ }
106+ }
107+ }
108+ ```
109+
110+ Then in your component:
111+
112+ ``` html
113+ <ngx-input-counter [(ngModel)] =" qty" class =" custom" ></ngx-input-counter >
114+ ```
115+
116+ You can use the Input props ` minusClass ` , ` plusClass ` and ` valueClass ` to override the default value class and use your own classes, this is usefull if you are using CSS frameworks.
117+
118+ ``` html
119+ <ngx-input-counter
120+ ...
121+ minusClass =" btn btn-info"
122+ plusClass =" btn btn-primary"
123+ ></ngx-input-counter >
124+ ```
125+
126+ If you want to use custom icons in the counter buttons use the ` minusTemplate ` and ` plusTemplate ` passing a TemplateRef with the content you want to show
127+
128+ ``` html
129+ <ng-template #plusTemplate >
130+ <svg xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24" stroke-width =" 1.5" stroke =" currentColor" >
131+ <path stroke-linecap =" round" stroke-linejoin =" round" d =" M12 4.5v15m7.5-7.5h-15" />
132+ </svg >
133+ </ng-template >
134+ <ng-template #minusTemplate >
135+ <svg xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24" stroke-width =" 1.5" stroke =" currentColor" >
136+ <path stroke-linecap =" round" stroke-linejoin =" round" d =" M19.5 12h-15" />
137+ </svg >
138+ </ng-template >
139+
140+ <ngx-input-counter
141+ class =" custom-class"
142+ [plusTemplate] =" plusTemplate"
143+ [minusTemplate] =" minusTemplate"
144+ ></ngx-input-counter >
145+ ```
146+
147+ You can use the slot, using ` minus ` for the ` minusTemplate ` and ` plus ` for the ` plusTemplate ` slot
148+
149+ ``` html
150+ <ngx-input-counter >
151+ <ng-template plus >
152+ <svg xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24" stroke-width =" 1.5" stroke =" currentColor" >
153+ <path stroke-linecap =" round" stroke-linejoin =" round" d =" M12 4.5v15m7.5-7.5h-15" />
154+ </svg >
155+ </ng-template >
156+ <ng-template minus >
157+ <svg xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24" stroke-width =" 1.5" stroke =" currentColor" >
158+ <path stroke-linecap =" round" stroke-linejoin =" round" d =" M19.5 12h-15" />
159+ </svg >
160+ </ng-template >
161+ </ngx-input-counter >
162+ ```
163+
164+ When you use the slot template you can pass classes to override the button class:
165+
166+ ``` html
167+ <ng-template minus class =" rounded p-4" >
168+ <svg xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24" stroke-width =" 1.5" stroke =" currentColor" >
169+ <path stroke-linecap =" round" stroke-linejoin =" round" d =" M19.5 12h-15" />
170+ </svg >
171+ </ng-template >
172+ ```
173+
66174## Development
67175
68176Clone this repo and install the dependencies. Run ` ng serve ` for a dev server. Navigate to ` http://localhost:4200/ ` . The application will automatically reload if you change any of the source files.
0 commit comments