1| # Slider button card by @mattieha
2| [![GitHub Release][releases-shield]][releases]
3|
4|
5| A button card with integrated slider for
light, switch, fan, cover, input_boolean, media_player, climate, lock entities.
6|
7| ![Preview][preview]
8| ![Preview 2][preview-2]
9|
10| #### Please ⭐️ this repo if you find it useful
11|
12| ## TOC
13| - Installation
14| - HACS
15| - Manual
16| - Configuration
17| - Visual Editor
18| - Options
19| - Icon options
20| - Slider options
21| - Action button options
22| - Tap action
23| - Styles
24| - Examples
25| - Minimal working config
26| - Per feature
27| - General
28| - Icon
29| - Action button
30| - Slider
31| - Full examples
32| - Fan
33| - Switch
34| - Cover
35| - Media player
36| - Climate
37| - Lock
38| - In a grid
39| - Group support
40| - Known issues
41| - Languages
42| - Credits
43|
44| ## Installation
45|
46| ### HACS
47| This card is available in [HACS][hacs] (Home Assistant Community Store).
48| Just search for Slider Button Card in Frontend tab.
49|
50| ### Manual
51|
52| 1. Download slider-button-card.js file from the [latest-release].
53| 2. Put slider-button-card.js file into your config/www folder.
54| 3. Go to Configuration → Lovelace Dashboards → Resources → Click Plus button → Set Url as /local/slider-button-card.js → Set Resource type as JavaScript Module.
55| 4. Add custom:slider-button-card to Lovelace UI as any other card (using either editor or YAML configuration).
56|
57| ## Configuration
58|
59| ### Visual Editor
60|
61| Slider Button Card supports Lovelace's Visual Editor.
62|
Show screenshot
63| 64| ![Visual Editor][visual-editor] 65|custom:slider-button-card |
73| | entity | string | Required | HA entity ID from domain light, switch, fan, cover, input_boolean, media_player, climate, lock | |
74| | name | string | Optional | Name | entity.friendly_name |
75| | show_name | boolean | Optional | Show name | true |
76| | show_state | boolean | Optional | Show state | true |
77| | compact | boolean | Optional | Compact mode, display name and state inline with icon. Useful for full width cards. | false |
78| | icon | object | Optional | Icon options | |
79| | slider | object | Optional | Slider options | |
80| | action_button | object/array | Optional | Action button options - Can be a single object or array of up to 5 buttons | |
81|
82| ### Icon Options
83|
84| | Name | Type | Requirement | Description | Default |
85| | ----------------- | ------- | ------------ | ------------------------------------------- | ------------------- |
86| | icon | string | Optional | Icon | default entity icon |
87| | show | boolean | Optional | Show icon | true |
88| | use_state_color | boolean | Optional | Use state color | true |
89| | tap_action | object | Optional | Action to take on tap | action: more-info |
90|
91| ### Slider Options
92|
93| | Name | Type | Requirement | Description | Default |
94| | ----------------- | ------- | ------------ | ------------------------------------------- | ------------------- |
95| | direction | string | Optional | Direction left-right, top-bottom, bottom-top | left-right |
96| | background | string | Optional | Background solid, gradient, triangle, striped, custom | gradient |
97| | use_state_color | boolean | Optional | Use state color | true |
98| | use_percentage_bg_opacity | boolean | Optional | Apply opacity to background based on percentage | true |
99| | show_track | boolean | Optional | Show track when state is on | false |
100| | always_show_track | boolean | Optional | Always show slider track, even when entity is Off or at 0 | false |
101| | track_background_color | string | Optional | Card track background color for non-filled area. Use any valid CSS color or transparent | #2b374e |
102| | track_size_percent | number | Optional | Set length of slider track as percentage of card height/width (1-100). Based on slider direction. | 100 |
103| | force_square | boolean | Optional | Force the button as a square | false |
104| | toggle_on_click | boolean | Optional | Force the slider to act as a toggle, if true sliding is disabled | false |
105| | attribute | string | Optional | Control an attribute for light or cover entities | |
106| | invert | boolean | Optional | Invert calculation of state and percentage, useful for cover entities | falsetrue for cover |
107|
108| ### Attributes
109| Light:
110| - brightness_pct default
111| - brightness
112| - color_temp
113| - hue
114| - saturation115| 116| Warning options other than
brightness_pct and brightness may give strange results
117|
118| For example when color_temp is selected as attribute and the current color_mode of the light is not color_temp there is no value available for the slider, so the min value will be displayed.
119|
120| Cover:
121| - position default
122| - tilt
123| ### Action button Options
124|
125| | Name | Type | Requirement | Description | Default |
126| | ----------------- | ------- | ------------ | ------------------------------------------- | ------------------- |
127| | mode | string | Optional | Mode toggle, custom | toggle |
128| | show | boolean | Optional | Show the action button | true |
129| | icon | string | Optional | Icon when mode is custom | mdi:power |
130| | show_spinner | boolean | Optional | Show spinner when mode is custom | true |
131| | tap_action | object | Optional | Action to take on tap | action: toggle |
132|
133| #### Multiple Action Buttons
134|
134| Support for up to 5 action buttons. Configure as an array:
135|
135| yaml 136| action_button: 137| - mode: custom 138| icon: mdi:power 139| show: true 140| tap_action: 141| action: toggle 141| - mode: custom 142| icon: mdi:brightness-high 143| show: true 144| tap_action: 145| action: call-service 146| service: light.turn_on 147| service_data: 148| entity_id: light.living_room 149| brightness_pct: 100 150| - mode: custom 151| icon: mdi:palette 152| show: true 153| tap_action: 154| action: call-service 154| service: scene.turn_on 155| service_data: 156| entity_id: scene.party 157| - mode: custom 158| icon: mdi:music 159| show: true 159| tap_action: 160| action: call-service 160| service: media_player.media_play_pause 161| service_data: 162| entity_id: media_player.bedroom 163| - mode: custom 164| icon: mdi:home 164| show: true 165| tap_action: 166| action: navigate 166| navigation_path: /lovelace/media 167|
168|
169| ### Action Options
170|
171| | Name | Type | Requirement | Description | Default |
172| | --------------- | ------ | ------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
173| | action | string | Required | Action to perform (more-info, toggle, call-service, navigate url, none) | more-info |
174| | navigation_path | string | Optional | Path to navigate to (e.g. /lovelace/0/) when action defined as navigate | none |
175| | url | string | Optional | URL to open on click when action is url. The URL will open in a new tab | none |
176| | service | string | Optional | Service to call (e.g. media_player.media_play_pause) when action defined as call-service | none |
177| | service_data | object | Optional | Service data to include (e.g. entity_id: media_player.bedroom) when action defined as call-service | none |
178| | haptic | string | Optional | Haptic feedback for the Beta IOS App success, warning, failure, light, medium, heavy, selection | none |
179| | repeat | number | Optional | How often to repeat the hold_action in milliseconds. | non |
180| ### Styles
181| Custom styles can be set by using Card mod
182| yaml 183| style: | 184| :host { 185| --VARIABLE: VALUE; 186| } 187|
188|
189| | Variable | Description | Default |
190| | ----------------------- | ------------------------------------------- | ------------------- |
191| | --icon-color | Color of the icon when icon.use_state_color === false | var(--paper-item-icon-color) |
192| | --label-color-on | Color of the label when state is on | var(--primary-text-color, white) |
193| | --label-color-off | Color of the label when state is off | var(--primary-text-color, white) |
194| | --state-color-on | Color of the state value when state is on | var(--label-badge-text-color, white) |
195| | --state-color-off | Color of the state value when state is off | var(--disabled-text-color) |
196| | --action-icon-color-on | Color of the action button icon when state is on | var(--paper-item-icon-color, black) |
197| | --action-icon-color-off | Color of the action button icon when state is off | var(--paper-item-icon-color, black) |
198| | --action-spinner-color | Color of the spinner action button | var(--label-badge-text-color, white) |
199|
200| ## Examples
201|
202| ### Minimal working config
203|
204|
205|
206|
208|
209|
210|
212|
227|
228| | Compact, best used in full width (not in grid) 238| | |
![]() 242| |
244|
245| yaml 246| compact: true 247| 248| |
| Minimal config 258| | |
262| |
264|
265| yaml 266| icon: 267| tap_action: 268| action: more-info 269| 270| |
| Icon override 278| | |
282| |
284|
285| yaml 286| icon: 287| icon: mdi:lightbulb 288| tap_action: 289| action: more-info 290| 291| |
| Minimal config 302| | |
![]() 306| |
308|
309| yaml 310| action_button: 311| mode: toggle 312| show: true 313| 314| |
| Custom 322| | |
![]() 326| |
328|
329| yaml 330| action_button: 331| mode: custom 332| show: true 333| tap_action: 334| action: toggle 335| 336| |
| Minimal config 372| | |
![]() 376| |
378|
379| yaml 380| slider: 381| direction: left-right 382| background: gradient 383| 384| |
| Background uses color or color_temp if available 391| | |
![]() 395| |
397|
398| yaml 399| slider: 400| direction: left-right 401| background: gradient 402| use_state_color: true 403| 404| |
| Show track, best used in full width or triangle 412| | |
![]() 416| |
418|
419| yaml 420| slider: 421| direction: left-right 422| background: triangle 423| use_state_color: true 424| show_track: true 425| 426| |
| Force square 434| | |
![]() 437| |
439|
440| yaml 441| slider: 442| direction: left-right 443| background: triangle 444| use_state_color: true 445| show_track: true 446| force_square: true 447| 448| |
slider.toggle_on_click: true so the slider acts as a toggle (sliding is disabled).
532|
533|
534|
535|
537|
538|
539|
541|
561|
562| slider.direction: top-bottom and slider.background: striped;
566|
566|
567|
568|
570|
571|
572|
574|
592|
593| slider.toggle_on_click: true
664|
664|
665|
666|
668|
669|
670|
672|
688|
689| group entities are not supported, if you want to control multiple
756| - lights use Light group
757| - covers use Cover group
758| - media players use Media player group
759|
760| ## Known issues
761| When you discover any bugs please open an issue.
762|
763| ## Languages
764|
764| This card supports translations. Please, help to add more translations and improve existing ones. Here's a list of supported languages:
765|
766| - English
767| - French
768| - German
769| - Hebrew
770| - Nederlands (Dutch)
771| - Polish (polski)
772| - Portuguese
773| - Russian
774| - Korean
775| - [Your language?][add-translation]
776|
777| ## Credits
778| - Inspired by Slider entity row
778|
779| ---
780|
780|
781|
782| [hacs]: https://hacs.xyz
783| [add-translation]: https://github.com/mattieha/slider-button-card/blob/main/CONTRIBUTE.md#adding-a-new-translation
784| [visual-editor]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/card-editor.png
785| [preview]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/preview.gif
786| [preview-2]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/preview-2.gif
787| [grid]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/grid-not-square.png
788| [full-width]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/grid-full-width.png
789| [latest-release]: https://github.com/mattieha/slider-button-card/releases/latest
790| [releases-shield]: https://img.shields.io/github/release/mattieha/slider-button-card.svg?style=for-the-badge
791| [releases]: https://github.com/mattieha/slider-button-card/releases
792| [icon-minimal]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/grid-full-width.png
793|
















