Skip to content

Commit

Permalink
Merge pull request #5736 from Laravel-Backpack/fix-switch-field-bg-color
Browse files Browse the repository at this point in the history
fix switch bg color
  • Loading branch information
pxpm authored Dec 18, 2024
2 parents c09e3f3 + ca15c4e commit 6222ec5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/resources/views/crud/fields/switch.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div class="d-inline-flex align-items-center">
{{-- Switch --}}
<label class="form-switch switch switch-sm switch-label switch-pill switch-{{ $field['color'] }} mb-0" style="--bg-color: {{ $field['color'] }};">
<label class="form-switch switch switch-sm switch-label switch-pill switch-{{ $field['color'] }} mb-0" style="--bg-switch-checked-color: {{ $field['color'] }};">
<input
type="hidden"
name="{{ $field['name'] }}"
Expand All @@ -23,7 +23,8 @@
type="checkbox"
data-init-function="bpFieldInitSwitch"
{{ (bool) $field['value'] ? 'checked' : '' }}
class="switch-input form-check-input" />
class="switch-input form-check-input"
/>
<span
class="switch-slider"
data-checked="{{ $field['onLabel'] ?? '' }}"
Expand Down Expand Up @@ -86,7 +87,10 @@ function bpFieldInitSwitch($element) {
@bassetBlock('backpack/crud/fields/switch-field.css')
<style>
.switch-input:checked+.switch-slider {
background-color: var(--bg-color);
background-color: var(--bg-switch-checked-color);
}
.form-switch .form-check-input:checked {
background-color: var(--bg-switch-checked-color);
}
</style>
@endBassetBlock
Expand Down

0 comments on commit 6222ec5

Please sign in to comment.